My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
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 c55922a0706f92af8b81b4ae91ebefe870ebcab4 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 229f36e..99b2f3e 100644
--- a/openid.php
+++ b/openid.php
@@ -50,7 +50,8 @@ class LightOpenID
, $required = array()
, $optional = array()
, $verify_perr = null
- , $capath = null;
+ , $capath = null
+ , $strict = false;
private $identity, $claimed_id;
protected $server, $version, $trustRoot, $aliases, $identifier_select = false
, $ax = false, $sreg = false, $data;
@@ -347,11 +348,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