diff -ur Auth_OpenID-1.2.1/Services/Yadis/ParseHTML.php Auth_OpenID-my/Services/Yadis/ParseHTML.php
--- Auth_OpenID-1.2.1/Services/Yadis/ParseHTML.php	2006-12-08 17:57:56.000000000 -0500
+++ Auth_OpenID-my/Services/Yadis/ParseHTML.php	2007-02-13 01:37:08.000000000 -0500
@@ -30,18 +30,14 @@
     /**
      * @access private
      */
-    var $_tag_expr = "<%s\b(?!:)([^>]*?)(?:\/>|>(.*?)(?:<\/?%s\s*>|\Z))";
+    // Note that we don't have any use for distinguishing between 
+    // just a open tag and a self-closing tag (e.g. <img> vs. <img />)
+    var $_tag_expr = "<%s(?:.*?)?\/?>";
 
     /**
      * @access private
      */
-    var $_close_tag_expr = "<\/?%s\s*>";
-
-    /**
-     * @access private
-     */
-    var $_removed_re =
-           "<!--.*?-->|<!\[CDATA\[.*?\]\]>|<script\b(?!:)[^>]*>.*?<\/script>";
+    var $_close_tag_expr = "<\/%s\s*>";
 
     /**
      * @access private
@@ -50,13 +46,6 @@
 
     function Services_Yadis_ParseHTML()
     {
-        $this->_meta_find = sprintf("/<meta\b(?!:)([^>]*)(?!<)>/%s",
-                                    $this->_re_flags);
-
-        $this->_removed_re = sprintf("/%s/%s",
-                                     $this->_removed_re,
-                                     $this->_re_flags);
-
         $this->_attr_find = sprintf("/%s/%s",
                                     $this->_attr_find,
                                     $this->_re_flags);
@@ -121,43 +110,33 @@
     }
 
     /**
-     * Create a regular expression that will match an opening (and
-     * optional) closing tag of a given name.
+     * Create a regular expression that will match an opening tag of a 
+     * given name.
      *
      * @access private
      * @param string $tag_name The tag name to match
-     * @param array $close_tags An array of tag names which also
-     * constitute closing of the original tag
      * @return string $regex A regular expression string to be used
      * in, say, preg_match.
      */
-    function tagMatcher($tag_name, $close_tags = null)
+    function openTagPattern($tag_name)
     {
-        if ($close_tags) {
-            $options = implode("|", array_merge(array($tag_name), $close_tags));
-            $closer = sprintf("(?:%s)", $options);
-        } else {
-            $closer = $tag_name;
-        }
-
-        $expr = sprintf($this->_tag_expr, $tag_name, $closer);
+        $expr = sprintf($this->_tag_expr, $tag_name);
         return sprintf("/%s/%s", $expr, $this->_re_flags);
     }
 
     /**
+     * Create a regular expression that will match an closing tag of a 
+     * given name.
+     *
      * @access private
+     * @param string $tag_name The tag name to match
+     * @return string $regex A regular expression string to be used
+     * in, say, preg_match.
      */
-    function htmlFind($str)
-    {
-        return $this->tagMatcher('html', array('body'));
-    }
-
-    /**
-     * @access private
-     */
-    function headFind()
+    function closeTagPattern($tag_name)
     {
-        return $this->tagMatcher('head', array('body'));
+        $expr = sprintf($this->_close_tag_expr, $tag_name);
+        return sprintf("/%s/%s", $expr, $this->_re_flags);
     }
 
     /**
@@ -173,51 +152,41 @@
      */
     function getMetaTags($html_string)
     {
-        $stripped = preg_replace($this->_removed_re,
-                                 "",
-                                 $html_string);
-
-        // Look for the closing body tag.
-        $body_closer = sprintf($this->_close_tag_expr, 'body');
-        $body_matches = array();
-        preg_match($body_closer, $html_string, $body_matches,
-                   PREG_OFFSET_CAPTURE);
-        if ($body_matches) {
-            $html_string = substr($html_string, 0, $body_matches[0][1]);
-        }
-
-        // Look for the opening body tag, and discard everything after
-        // that tag.
-        $body_re = $this->tagMatcher('body');
-        $body_matches = array();
-        preg_match($body_re, $html_string, $body_matches, PREG_OFFSET_CAPTURE);
-        if ($body_matches) {
-            $html_string = substr($html_string, 0, $body_matches[0][1]);
-        }
-
-        // If an HTML tag is found at all, it must be in the right
-        // order; else, it may be missing (which is a case we allow
-        // for).
-        $html_re = $this->tagMatcher('html', array('body'));
-        preg_match($html_re, $html_string, $html_matches);
-        if ($html_matches) {
-            $html = $html_matches[0];
-        } else {
-            $html = $html_string;
+        // Look for tags that we want to ignore everything after.
+        // This will speed up later matching.
+        // Do this in the order that we're most likely to find things.
+        // e.g. the closing head tag should occur before the opening body tag.
+        $discard_tags = array($this->closeTagPattern('head'),
+                              $this->openTagPattern('body'),
+                              $this->closeTagPattern('body'),
+                              $this->closeTagPattern('html'));
+        foreach ($discard_tags as $pat) {
+            $matches = array();
+            preg_match($pat, $html_string, $matches, PREG_OFFSET_CAPTURE);
+            if($matches) {
+                $html_string = substr($html_string, 0, $matches[0][1]);
+                // only bother with one replacement,saving time on the
+                // assumption of some sanity
+                break;
+            }
         }
 
-        // Try to find the <HEAD> tag.
-        $head_re = $this->headFind();
-        $head_matches = array();
-        if (!preg_match($head_re, $html, $head_matches)) {
-            return array();
+        // Look for tags that we want to ignore everything before.
+        $discard_tags = array($this->openTagPattern('head'),
+                              $this->openTagPattern('html'));
+        foreach ($discard_tags as $pat) {
+            $matches = array();
+            preg_match($pat, $html_string, $matches, PREG_OFFSET_CAPTURE);
+            if($matches) {
+                $html_string = substr($html_string, $matches[0][1]+strlen($matches[0][0]));
+                break;
+            }
         }
 
         $link_data = array();
         $link_matches = array();
-
-        if (!preg_match_all($this->_meta_find, $head_matches[0],
-                            $link_matches)) {
+        
+        if (!preg_match_all($this->openTagPattern('meta'), $html_string, $link_matches)) {
             return array();
         }
 
