summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2007-10-01 21:40:46 +0000
committertailor <cygnus@janrain.com>2007-10-01 21:40:46 +0000
commit98ad3633c4cd059d9a3d3832c2e63c2a1e1b87db (patch)
tree2c88e86904c638c448ac3caf44c26f194cffea05
parentf809201a6b3648cc2e5f66619115710f604a38ef (diff)
downloadphp-openid-98ad3633c4cd059d9a3d3832c2e63c2a1e1b87db.zip
php-openid-98ad3633c4cd059d9a3d3832c2e63c2a1e1b87db.tar.gz
php-openid-98ad3633c4cd059d9a3d3832c2e63c2a1e1b87db.tar.bz2
[project @ Remove fragments as part of normalization]
-rw-r--r--Auth/OpenID.php9
-rw-r--r--Tests/Auth/OpenID/Discover_OpenID.php27
-rw-r--r--Tests/Auth/OpenID/data/openid.html11
3 files changed, 41 insertions, 6 deletions
diff --git a/Auth/OpenID.php b/Auth/OpenID.php
index 551dee6..9582f50 100644
--- a/Auth/OpenID.php
+++ b/Auth/OpenID.php
@@ -448,8 +448,7 @@ class Auth_OpenID {
if (($parsed['scheme'] == '') ||
($parsed['host'] == '')) {
if ($parsed['path'] == '' &&
- $parsed['query'] == '' &&
- $parsed['fragment'] == '') {
+ $parsed['query'] == '') {
return null;
}
@@ -461,15 +460,13 @@ class Auth_OpenID {
$tail = array_map(array('Auth_OpenID', 'quoteMinimal'),
array($parsed['path'],
- $parsed['query'],
- $parsed['fragment']));
+ $parsed['query']));
if ($tail[0] == '') {
$tail[0] = '/';
}
$url = Auth_OpenID::urlunparse($parsed['scheme'], $parsed['host'],
- $parsed['port'], $tail[0], $tail[1],
- $tail[2]);
+ $parsed['port'], $tail[0], $tail[1]);
assert(is_string($url));
diff --git a/Tests/Auth/OpenID/Discover_OpenID.php b/Tests/Auth/OpenID/Discover_OpenID.php
index 250a29e..369f77b 100644
--- a/Tests/Auth/OpenID/Discover_OpenID.php
+++ b/Tests/Auth/OpenID/Discover_OpenID.php
@@ -279,6 +279,33 @@ class Tests_Auth_OpenID_Discover_OpenID extends _DiscoveryBase {
false);
}
+ /*
+ * Ensure that the Claimed Identifier does not have a fragment if
+ * one is supplied in the User Input.
+ */
+ function test_html1Fragment()
+ {
+ $data = Tests_Auth_OpenID_readdata('openid.html');
+ $content_type = 'text/html';
+ $expected_services = 1;
+
+ $this->fetcher->documents[$this->id_url] = array($content_type, $data);
+ $expected_id = $this->id_url;
+ $this->id_url = $this->id_url . '#fragment';
+ list($id_url, $services) = Auth_OpenID_discover($this->id_url, $this->fetcher);
+ $this->assertEquals($expected_services, count($services));
+ $this->assertEquals($expected_id, $id_url);
+
+ $this->_checkService(
+ $services[0],
+ "http://www.myopenid.com/server",
+ $expected_id,
+ 'http://smoker.myopenid.com/',
+ null,
+ array('1.1'),
+ false);
+ }
+
function test_html2()
{
$services = $this->_discover('text/html',
diff --git a/Tests/Auth/OpenID/data/openid.html b/Tests/Auth/OpenID/data/openid.html
new file mode 100644
index 0000000..1a57d44
--- /dev/null
+++ b/Tests/Auth/OpenID/data/openid.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <title>Identity Page for Smoker</title>
+ <link rel="openid.server" href="http://www.myopenid.com/server" />
+ <link rel="openid.delegate" href="http://smoker.myopenid.com/" />
+ </head>
+ <body>
+ <p>foo</p>
+ </body>
+</html>