Skip to content

Commit b8d3eff

Browse files
author
tailor
committed
[project @ Make yadis META tag search ignore comments]
1 parent d699e63 commit b8d3eff

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Auth/Yadis/ParseHTML.php

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ class Auth_Yadis_ParseHTML {
2727
*/
2828
var $_re_flags = "si";
2929

30+
/**
31+
* @access private
32+
*/
33+
var $_removed_re =
34+
"<!--.*?-->|<!\[CDATA\[.*?\]\]>|<script\b(?!:)[^>]*>.*?<\/script>";
35+
3036
/**
3137
* @access private
3238
*/
@@ -43,6 +49,10 @@ function Auth_Yadis_ParseHTML()
4349
$this->_attr_find,
4450
$this->_re_flags);
4551

52+
$this->_removed_re = sprintf("/%s/%s",
53+
$this->_removed_re,
54+
$this->_re_flags);
55+
4656
$this->_entity_replacements = array(
4757
'amp' => '&',
4858
'lt' => '<',
@@ -146,6 +156,10 @@ function tagPattern($tag_names, $close, $self_close)
146156
*/
147157
function getMetaTags($html_string)
148158
{
159+
$html_string = preg_replace($this->_removed_re,
160+
"",
161+
$html_string);
162+
149163
$key_tags = array($this->tagPattern('html', false, false),
150164
$this->tagPattern('head', false, false),
151165
$this->tagPattern('head', true, false),

Tests/Auth/Yadis/data/test1-parsehtml.txt

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ None
9696
<html><head><body><meta http-equiv="X-XRDS-Location" content="found">
9797

9898
None
99+
<!-- <meta> is inside comment -->
100+
<html>
101+
<head>
102+
<!--<meta http-equiv="X-XRDS-Location" content="found">-->
103+
</head>
104+
</html>
105+
106+
None
99107
<!-- <meta> is inside of <body> -->
100108
<html>
101109
<head>

0 commit comments

Comments
 (0)