diff options
-rw-r--r-- | Auth/OpenID/TrustRoot.php | 17 | ||||
-rw-r--r-- | Tests/Auth/OpenID/data/trustroot.txt | 8 |
2 files changed, 20 insertions, 5 deletions
diff --git a/Auth/OpenID/TrustRoot.php b/Auth/OpenID/TrustRoot.php index 94e3b99..1e9df2c 100644 --- a/Auth/OpenID/TrustRoot.php +++ b/Auth/OpenID/TrustRoot.php @@ -201,11 +201,22 @@ function Auth_OpenID_matchTrustRoot($trust_root, $url) } } - // Check path matching + // Check path and query matching $base_path = $trust_root_parsed['path']; $path = $url_parsed['path']; - if (substr($path, 0, strlen($base_path)) != $base_path) { - return false; + if (!isset($trust_root_parsed['query'])) { + if (substr($path, 0, strlen($base_path)) != $base_path) { + return false; + } + } else { + $base_query = $trust_root_parsed['query']; + $query = @$url_parsed['query']; + $qplus = substr($query, 0, strlen($base_query) + 1); + $bqplus = $base_query . '&'; + if ($base_path != $path || + ($base_query != $query && $qplus != $bqplus)) { + return false; + } } // The port and scheme need to match exactly diff --git a/Tests/Auth/OpenID/data/trustroot.txt b/Tests/Auth/OpenID/data/trustroot.txt index 0db7f50..cdfb773 100644 --- a/Tests/Auth/OpenID/data/trustroot.txt +++ b/Tests/Auth/OpenID/data/trustroot.txt @@ -59,7 +59,7 @@ return_to matching ======================================== ---------------------------------------- -29: matches +30: matches ---------------------------------------- http://*/ http://cnn.com/ http://*/ http://livejournal.com/ @@ -90,9 +90,10 @@ http://goathack.livejournal.org:8020/ http://goathack.livejournal.org:8020/openi https://foo.com https://foo.com http://Foo.com http://foo.com http://foo.com http://Foo.com +http://foo.com/?x=y http://foo.com/?x=y&a=b ---------------------------------------- -19: does not match +22: does not match ---------------------------------------- http://*/ ftp://foo.com/ http://*/ xxx @@ -113,3 +114,6 @@ http://foo.com:80 http://foo.com http://foo.com http://foo.com:80 http://foo.com:81 http://foo.com:80 http://*:80 http://foo.com:81 +http://foo.com/?a=b http://foo.com/?x=y +http://foo.com/?a=b http://foo.com/?x=y&a=b +http://foo.com/?a=b http://foo.com/ |