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 "Integration tests for FirejailCommand"
[lhc/web/wiklou.git]
/
includes
/
search
/
SearchHighlighter.php
diff --git
a/includes/search/SearchHighlighter.php
b/includes/search/SearchHighlighter.php
index
d0e3a24
..
20462cf
100644
(file)
--- a/
includes/search/SearchHighlighter.php
+++ b/
includes/search/SearchHighlighter.php
@@
-29,6
+29,11
@@
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.
+ * @param bool $cleanupWikitext
+ */
function __construct( $cleanupWikitext = true ) {
$this->mCleanWikitext = $cleanupWikitext;
}
function __construct( $cleanupWikitext = true ) {
$this->mCleanWikitext = $cleanupWikitext;
}
@@
-287,8
+292,8
@@
class SearchHighlighter {
/**
* Split text into lines and add it to extracts array
*
/**
* Split text into lines and add it to extracts array
*
- * @param array $extracts Index -> $line
- * @param int $count
+ * @param array
&
$extracts Index -> $line
+ * @param int
&
$count
* @param string $text
*/
function splitAndAdd( &$extracts, &$count, $text ) {
* @param string $text
*/
function splitAndAdd( &$extracts, &$count, $text ) {
@@
-322,8
+327,8
@@
class SearchHighlighter {
* @param string $text
* @param int $start
* @param int $end
* @param string $text
* @param int $start
* @param int $end
- * @param int $posStart (out) actual start position
- * @param int $posEnd (out) actual end position
+ * @param int
&
$posStart (out) actual start position
+ * @param int
&
$posEnd (out) actual end position
* @return string
*/
function extract( $text, $start, $end, &$posStart = null, &$posEnd = null ) {
* @return string
*/
function extract( $text, $start, $end, &$posStart = null, &$posEnd = null ) {
@@
-393,10
+398,10
@@
class SearchHighlighter {
*
* @param string $pattern Regexp for matching lines
* @param array $extracts Extracts to search
*
* @param string $pattern Regexp for matching lines
* @param array $extracts Extracts to search
- * @param int $linesleft Number of extracts to make
- * @param int $contextchars Length of snippet
- * @param array $out Map for highlighted snippets
- * @param array $offsets Map of starting points of snippets
+ * @param int
&
$linesleft Number of extracts to make
+ * @param int
&
$contextchars Length of snippet
+ * @param array
&
$out Map for highlighted snippets
+ * @param array
&
$offsets Map of starting points of snippets
* @protected
*/
function process( $pattern, $extracts, &$linesleft, &$contextchars, &$out, &$offsets ) {
* @protected
*/
function process( $pattern, $extracts, &$linesleft, &$contextchars, &$out, &$offsets ) {
@@
-456,6
+461,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;
}