My favorites
▼
|
Sign in
lightopenid
Lightweight OpenID library.
Project Home
Downloads
Wiki
Issues
Source
Export to GitHub
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
14
attachment: 0001-allowed-more-types-of-yadis-xml-file.patch
(2.6 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From 8776a996ed6abfa52e6043835933e28026946fa3 Mon Sep 17 00:00:00 2001
From: Jan Dolecek <juzna.cz@gmail.com>
Date: Tue, 2 Nov 2010 11:29:37 +0000
Subject: [PATCH] allowed more types of yadis xml file
---
openid.php | 28 +++++++++++++++++++++++-----
1 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/openid.php b/openid.php
index c01f8ae..c385f81 100644
--- a/openid.php
+++ b/openid.php
@@ -48,7 +48,8 @@ class LightOpenID
{
public $returnUrl
, $required = array()
- , $optional = array();
+ , $optional = array()
+ , $strict = false;
private $identity, $claimed_id;
protected $server, $version, $trustRoot, $aliases, $identifier_select = false
, $ax = false, $sreg = false, $data;
@@ -276,11 +277,28 @@ class LightOpenID
$next = true;
}
- if (isset($headers['content-type'])
- && strpos($headers['content-type'], 'application/xrds+xml') !== false
- ) {
- # Found an XRDS document, now let's find the server, and optionally delegate.
+ // Get ContentType header
+ if(isset($headers['content-type'])) {
+ $contentType = $headers['content-type'];
+ $pos = strpos($contentType, ';');
+ if($pos !== false) $contentType = substr($contentType, 0, $pos);
+ }
+ else $contentType = null;
+
+ // Check whether it's XRDS document
+ $isXrdsDocument = false;
+ $content = null;
+ if(isset($contentType)) {
+ if($contentType == 'application/xrds+xml') $isXrdsDocument = true;
+ elseif(!$this->strict && ($contentType == 'text/xml' || $contentType == 'text/plain')) { // Guess, if it's XRDS with wrong MIME type?
$content = $this->request($url, 'GET');
+ $isXrdsDocument = strpos($content, 'xri://$xrds') !== false && strpos($content, 'xri://$xrd*($v*2.0)') !== false;
+ }
+ }
+
+ if ($isXrdsDocument) {
+ # Found an XRDS document, now let's find the server, and optionally delegate.
+ if(!isset($content)) $content = $this->request($url, 'GET');
preg_match_all('#<Service.*?>(.*?)</Service>#s', $content, $m);
foreach($m[1] as $content) {
--
1.7.0.4
Powered by
Google Project Hosting