dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Sanitizer: Allow attribute names to use any Unicode "Letter" or "Number""
[lhc/web/wiklou.git]
/
includes
/
search
/
SearchHighlighter.php
diff --git
a/includes/search/SearchHighlighter.php
b/includes/search/SearchHighlighter.php
index
dd41a6e
..
cebdb40
100644
(file)
--- a/
includes/search/SearchHighlighter.php
+++ b/
includes/search/SearchHighlighter.php
@@
-29,6
+29,10
@@
class SearchHighlighter {
protected $mCleanWikitext = true;
class SearchHighlighter {
protected $mCleanWikitext = true;
+ /**
+ * @warning If you pass false to this constructor, then
+ * the caller is responsible for HTML escaping.
+ */
function __construct( $cleanupWikitext = true ) {
$this->mCleanWikitext = $cleanupWikitext;
}
function __construct( $cleanupWikitext = true ) {
$this->mCleanWikitext = $cleanupWikitext;
}
@@
-75,10
+79,10
@@
class SearchHighlighter {
if ( preg_match( $spat, $text, $matches, PREG_OFFSET_CAPTURE, $start ) ) {
$epat = '';
foreach ( $matches as $key => $val ) {
if ( preg_match( $spat, $text, $matches, PREG_OFFSET_CAPTURE, $start ) ) {
$epat = '';
foreach ( $matches as $key => $val ) {
- if ( $key > 0 && $val[1] != -
1 ) {
+ if ( $key > 0 && $val[1] != -1 ) {
if ( $key == 2 ) {
// see if this is an image link
if ( $key == 2 ) {
// see if this is an image link
- $ns = substr( $val[0], 2, -
1 );
+ $ns = substr( $val[0], 2, -1 );
if ( $wgContLang->getNsIndex( $ns ) != NS_FILE ) {
break;
}
if ( $wgContLang->getNsIndex( $ns ) != NS_FILE ) {
break;
}
@@
-252,10
+256,10
@@
class SearchHighlighter {
// $snippets = array_map( 'htmlspecialchars', $extended );
$snippets = $extended;
// $snippets = array_map( 'htmlspecialchars', $extended );
$snippets = $extended;
- $last = -
1;
+ $last = -1;
$extract = '';
foreach ( $snippets as $index => $line ) {
$extract = '';
foreach ( $snippets as $index => $line ) {
- if ( $last == -
1 ) {
+ if ( $last == -1 ) {
$extract .= $line; // first line
} elseif ( $last + 1 == $index
&& $offsets[$last] + strlen( $snippets[$last] ) >= strlen( $all[$last] )
$extract .= $line; // first line
} elseif ( $last + 1 == $index
&& $offsets[$last] + strlen( $snippets[$last] ) >= strlen( $all[$last] )
@@
-456,6
+460,10
@@
class SearchHighlighter {
$text = preg_replace( "/('''|<\/?[iIuUbB]>)/", "", $text );
$text = preg_replace( "/''/", "", $text );
$text = preg_replace( "/('''|<\/?[iIuUbB]>)/", "", $text );
$text = preg_replace( "/''/", "", $text );
+ // Note, the previous /<\/?[^>]+>/ is insufficient
+ // for XSS safety as the HTML tag can span multiple
+ // search results (T144845).
+ $text = Sanitizer::escapeHtmlAllowEntities( $text );
return $text;
}
return $text;
}