summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLilli <lilli@janrain.com>2010-02-12 12:12:36 -0800
committerLilli <lilli@janrain.com>2010-02-12 12:12:36 -0800
commit7521906f3b7d76a850523baa7216a725f234ddf4 (patch)
treeb1d70b8aaf01064c890180fa48e7e1c405eb68fc
parent8b258060a625290369560f0aca692521c7101b9c (diff)
downloadphp-openid-7521906f3b7d76a850523baa7216a725f234ddf4.zip
php-openid-7521906f3b7d76a850523baa7216a725f234ddf4.tar.gz
php-openid-7521906f3b7d76a850523baa7216a725f234ddf4.tar.bz2
Added the following patch from the dev@openidenabled.com mailing list:
http://lists.openidenabled.com/pipermail/dev/attachments/20090109/7e344691/attachment-0001.bin Original Message: ketmar at ketmar.no-ip.org ketmar at ketmar.no-ip.org Fri Jan 9 07:51:35 PST 2009 darcs patch: fix for incomplete URIs in "location" http field (for ... "* fix for incomplete URIs in "location" http field (for technorati and maybe others)" This patch was in the form of a Darcs patch, not a normal patch. So solve this, I applied it to the Darcs repository found on openidenabled, then created a new diff file between the original Darcs repo and the new one (with the patch applied) so that I could apply it to this git repo. Hunks were applied successfully.
-rw-r--r--Auth/Yadis/HTTPFetcher.php32
-rw-r--r--Auth/Yadis/ParanoidHTTPFetcher.php2
-rw-r--r--Auth/Yadis/PlainHTTPFetcher.php2
3 files changed, 32 insertions, 4 deletions
diff --git a/Auth/Yadis/HTTPFetcher.php b/Auth/Yadis/HTTPFetcher.php
index 6053410..148cde1 100644
--- a/Auth/Yadis/HTTPFetcher.php
+++ b/Auth/Yadis/HTTPFetcher.php
@@ -115,12 +115,40 @@ class Auth_Yadis_HTTPFetcher {
/**
* @access private
*/
- function _findRedirect($headers)
+ function _findRedirect($headers, $url)
{
foreach ($headers as $line) {
if (strpos(strtolower($line), "location: ") === 0) {
$parts = explode(" ", $line, 2);
- return $parts[1];
+ $loc = $parts[1];
+ $ppos = strpos($loc, "://");
+ if ($ppos === false || $ppos > strpos($loc, "/")) {
+ /* no host; add it */
+ $hpos = strpos($url, "://");
+ $prt = substr($url, 0, $hpos+3);
+ $url = substr($url, $hpos+3);
+ if (substr($loc, 0, 1) == "/") {
+ /* absolute path */
+ $fspos = strpos($url, "/");
+ if ($fspos) $loc = $prt.substr($url, 0, $fspos).$loc;
+ else $loc = $prt.$url.$loc;
+ } else {
+ /* relative path */
+ $pp = $prt;
+ while (1) {
+ $xpos = strpos($url, "/");
+ if ($xpos === false) break;
+ $apos = strpos($url, "?");
+ if ($apos !== false && $apos < $xpos) break;
+ $apos = strpos($url, "&");
+ if ($apos !== false && $apos < $xpos) break;
+ $pp .= substr($url, 0, $xpos+1);
+ $url = substr($url, $xpos+1);
+ }
+ $loc = $pp.$loc;
+ }
+ }
+ return $loc;
}
}
return null;
diff --git a/Auth/Yadis/ParanoidHTTPFetcher.php b/Auth/Yadis/ParanoidHTTPFetcher.php
index 605aecd..ecc1821 100644
--- a/Auth/Yadis/ParanoidHTTPFetcher.php
+++ b/Auth/Yadis/ParanoidHTTPFetcher.php
@@ -142,7 +142,7 @@ class Auth_Yadis_ParanoidHTTPFetcher extends Auth_Yadis_HTTPFetcher {
}
if (in_array($code, array(301, 302, 303, 307))) {
- $url = $this->_findRedirect($headers);
+ $url = $this->_findRedirect($headers, $url);
$redir = true;
} else {
$redir = false;
diff --git a/Auth/Yadis/PlainHTTPFetcher.php b/Auth/Yadis/PlainHTTPFetcher.php
index af441ca..2689053 100644
--- a/Auth/Yadis/PlainHTTPFetcher.php
+++ b/Auth/Yadis/PlainHTTPFetcher.php
@@ -122,7 +122,7 @@ class Auth_Yadis_PlainHTTPFetcher extends Auth_Yadis_HTTPFetcher {
$code = $http_code[1];
if (in_array($code, array('301', '302'))) {
- $url = $this->_findRedirect($headers);
+ $url = $this->_findRedirect($headers, $url);
$redir = true;
} else {
$redir = false;