Index: modules/openid/openid.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.inc,v
retrieving revision 1.19
diff -u -p -r1.19 openid.inc
--- modules/openid/openid.inc	15 Sep 2009 19:46:04 -0000	1.19
+++ modules/openid/openid.inc	17 Sep 2009 07:55:24 -0000
@@ -151,6 +151,13 @@ function _openid_normalize_url($url) {
     $normalized_url = 'http://' . $url;
   }
 
+  // Strip the fragment and fragment delimiter if present.
+  $fragment = strpos($normalized_url, '#');
+
+  if ($fragment !== FALSE) {
+    $normalized_url = substr($normalized_url, 0, $fragment);
+  }
+
   if (substr_count($normalized_url, '/') < 3) {
     $normalized_url .= '/';
   }
Index: modules/openid/openid.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.test,v
retrieving revision 1.5
diff -u -p -r1.5 openid.test
--- modules/openid/openid.test	15 Sep 2009 19:46:04 -0000	1.5
+++ modules/openid/openid.test	17 Sep 2009 07:55:24 -0000
@@ -249,4 +249,24 @@ class OpenIDUnitTest extends DrupalWebTe
     $this->assertFalse(_openid_is_xri('user@example.com/'), t('_openid_is_xri returned expected result for an http URL.'));
     $this->assertFalse(_openid_is_xri('http://user@example.com/'), t('_openid_is_xri returned expected result for an http URL.'));
   }
+
+  /**
+   * Test _openid_normalize().
+   */
+  function testOpenidNormalize() {
+    // Test that the normalization is according to OpenID Authentication 2.0,
+    // section 7.2 and 11.5.2.
+
+    $this->assertEqual(_openid_normalize('$foo'), '$foo', t('_openid_normalize correctly normalized an XRI.'));
+    $this->assertEqual(_openid_normalize('xri://$foo'), '$foo', t('_openid_normalize correctly normalized an XRI with an xri:// scheme.'));
+
+    $this->assertEqual(_openid_normalize('example.com/'), 'http://example.com/', t('_openid_normalize correctly normalized a URL with a missing scheme.'));
+    $this->assertEqual(_openid_normalize('example.com'), 'http://example.com/', t('_openid_normalize correctly normalized a URL with a missing scheme and empty path.'));
+    $this->assertEqual(_openid_normalize('http://example.com'), 'http://example.com/', t('_openid_normalize correctly normalized a URL with an empty path.'));
+
+    $this->assertEqual(_openid_normalize('http://example.com/path'), 'http://example.com/path', t('_openid_normalize correctly normalized a URL with a path.'));
+
+    $this->assertEqual(_openid_normalize('http://example.com/path#fragment'), 'http://example.com/path', t('_openid_normalize correctly normalized a URL with a fragment.'));
+  }
+
 }
