summaryrefslogtreecommitdiff
path: root/extlib/Auth/Yadis/HTTPFetcher.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-06-29 10:24:48 -0400
committerBrion Vibber <brion@pobox.com>2010-06-29 10:24:48 -0400
commit2d920e05d563c9c327cf235b31ce18dfc4a83870 (patch)
tree31f3cde800220484cd242a8c4138c166307a2dea /extlib/Auth/Yadis/HTTPFetcher.php
parent923d9ef71ce49bfa55460bf42acb8a35bf3e84be (diff)
Update the (formerly) Janrain OpenID library to 2.2.2 -- bug fixes including PHP 5.3 compatibility fix.
Upstream release was tagged at: http://github.com/openid/php-openid/commit/a287b2d85e753c84b3b883ed8ee3ffe8692c8477
Diffstat (limited to 'extlib/Auth/Yadis/HTTPFetcher.php')
-rw-r--r--extlib/Auth/Yadis/HTTPFetcher.php33
1 files changed, 30 insertions, 3 deletions
diff --git a/extlib/Auth/Yadis/HTTPFetcher.php b/extlib/Auth/Yadis/HTTPFetcher.php
index 963b9a49a..148cde1b2 100644
--- a/extlib/Auth/Yadis/HTTPFetcher.php
+++ b/extlib/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;
@@ -144,4 +172,3 @@ class Auth_Yadis_HTTPFetcher {
}
}
-?> \ No newline at end of file