summaryrefslogtreecommitdiff
path: root/includes/common.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-09-04 17:55:43 +0000
committerDries Buytaert <dries@buytaert.net>2010-09-04 17:55:43 +0000
commit9d912261e30e597c883e20bc3a89416c28cd8e53 (patch)
tree1dacbab06e2d2ff51c1a28f350bf352ddb4fc8c2 /includes/common.inc
parent9502260ecf33a4b345794eea2d0b6e6dff5dbd74 (diff)
downloadbrdo-9d912261e30e597c883e20bc3a89416c28cd8e53.tar.gz
brdo-9d912261e30e597c883e20bc3a89416c28cd8e53.tar.bz2
- Patch #559584 by tic2000, sun: filter_xss() and Line break filter break HTML comments. Also added tests.
Diffstat (limited to 'includes/common.inc')
-rw-r--r--includes/common.inc13
1 files changed, 12 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 79a3fc6fa..a70d26e93 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1355,6 +1355,8 @@ function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite',
(
<(?=[^a-zA-Z!/]) # a lone <
| # or
+ <!--.*?--> # a comment
+ | # or
<[^>]*(>|$) # a string that starts with a <, up until the > or the end of the string
| # or
> # just a >
@@ -1393,7 +1395,7 @@ function _filter_xss_split($m, $store = FALSE) {
return '&lt;';
}
- if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) {
+ if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?|(<!--.*?-->)$%', $string, $matches)) {
// Seriously malformed
return '';
}
@@ -1401,12 +1403,21 @@ function _filter_xss_split($m, $store = FALSE) {
$slash = trim($matches[1]);
$elem = &$matches[2];
$attrlist = &$matches[3];
+ $comment = &$matches[4];
+
+ if ($comment) {
+ $elem = '!--';
+ }
if (!isset($allowed_html[strtolower($elem)])) {
// Disallowed HTML element
return '';
}
+ if ($comment) {
+ return $comment;
+ }
+
if ($slash != '') {
return "</$elem>";
}