* (bug 13756) Don't show the form and navigation links of Special:Newpages if
the page is included
* When hiding things on WhatLinksHere, generated URLs should hide them too
-* Properly escape search terms with forward slashes so they appear highlighted
- in search results.
+* Properly escape search terms with regex chars so they appear highlighted in
+ search results
=== API changes in 1.13 ===
}
/**
- * @param array $terms terms to highlight
+ * @param array $terms Terms to highlight (unescaped)
* @return string highlighted text snippet, null (and not '') if not supported
*/
function getTextSnippet($terms){
* Default implementation of snippet extraction
*
* @param string $text
- * @param array $terms
+ * @param array $terms Terms to highlight (unescaped)
* @param int $contextlines
* @param int $contextchars
* @return string
$fname = __METHOD__;
$lines = explode( "\n", $text );
-
+
+ foreach( $terms as $index => $term ) {
+ $terms[$index] = preg_quote( $term, '/' );
+ }
$terms = implode( '|', $terms );
- $terms = str_replace( '/', "\\/", $terms);
$max = intval( $contextchars ) + 1;
$pat1 = "/(.*)($terms)(.{0,$max})/i";