diff options
author | tailor <cygnus@janrain.com> | 2007-04-26 18:19:11 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2007-04-26 18:19:11 +0000 |
commit | b8d3eff26808d1907020b2d70674906e4f7e1d0e (patch) | |
tree | fd789c1c3eedeec8cd6d6bc7efe25c3f0c50dd57 | |
parent | d699e6340e49bb29f45748853d3a869476c07417 (diff) | |
download | php-openid-b8d3eff26808d1907020b2d70674906e4f7e1d0e.zip php-openid-b8d3eff26808d1907020b2d70674906e4f7e1d0e.tar.gz php-openid-b8d3eff26808d1907020b2d70674906e4f7e1d0e.tar.bz2 |
[project @ Make yadis META tag search ignore comments]
-rw-r--r-- | Auth/Yadis/ParseHTML.php | 14 | ||||
-rw-r--r-- | Tests/Auth/Yadis/data/test1-parsehtml.txt | 8 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Auth/Yadis/ParseHTML.php b/Auth/Yadis/ParseHTML.php index dd001ab..1922917 100644 --- a/Auth/Yadis/ParseHTML.php +++ b/Auth/Yadis/ParseHTML.php @@ -30,6 +30,12 @@ class Auth_Yadis_ParseHTML { /** * @access private */ + var $_removed_re = + "<!--.*?-->|<!\[CDATA\[.*?\]\]>|<script\b(?!:)[^>]*>.*?<\/script>"; + + /** + * @access private + */ var $_tag_expr = "<%s%s(?:\s.*?)?%s>"; /** @@ -43,6 +49,10 @@ class Auth_Yadis_ParseHTML { $this->_attr_find, $this->_re_flags); + $this->_removed_re = sprintf("/%s/%s", + $this->_removed_re, + $this->_re_flags); + $this->_entity_replacements = array( 'amp' => '&', 'lt' => '<', @@ -146,6 +156,10 @@ class Auth_Yadis_ParseHTML { */ function getMetaTags($html_string) { + $html_string = preg_replace($this->_removed_re, + "", + $html_string); + $key_tags = array($this->tagPattern('html', false, false), $this->tagPattern('head', false, false), $this->tagPattern('head', true, false), diff --git a/Tests/Auth/Yadis/data/test1-parsehtml.txt b/Tests/Auth/Yadis/data/test1-parsehtml.txt index e124380..b005c25 100644 --- a/Tests/Auth/Yadis/data/test1-parsehtml.txt +++ b/Tests/Auth/Yadis/data/test1-parsehtml.txt @@ -96,6 +96,14 @@ None <html><head><body><meta http-equiv="X-XRDS-Location" content="found"> None +<!-- <meta> is inside comment --> +<html> + <head> + <!--<meta http-equiv="X-XRDS-Location" content="found">--> + </head> +</html> + +None <!-- <meta> is inside of <body> --> <html> <head> |