Index: trunk/phase3/includes/SearchEngine.php |
— | — | @@ -545,7 +545,7 @@ |
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
549 | | - * @param array $terms terms to highlight |
| 549 | + * @param array $terms Terms to highlight (unescaped) |
550 | 550 | * @return string highlighted text snippet, null (and not '') if not supported |
551 | 551 | */ |
552 | 552 | function getTextSnippet($terms){ |
— | — | @@ -559,7 +559,7 @@ |
560 | 560 | * Default implementation of snippet extraction |
561 | 561 | * |
562 | 562 | * @param string $text |
563 | | - * @param array $terms |
| 563 | + * @param array $terms Terms to highlight (unescaped) |
564 | 564 | * @param int $contextlines |
565 | 565 | * @param int $contextchars |
566 | 566 | * @return string |
— | — | @@ -569,9 +569,11 @@ |
570 | 570 | $fname = __METHOD__; |
571 | 571 | |
572 | 572 | $lines = explode( "\n", $text ); |
573 | | - |
| 573 | + |
| 574 | + foreach( $terms as $index => $term ) { |
| 575 | + $terms[$index] = preg_quote( $term, '/' ); |
| 576 | + } |
574 | 577 | $terms = implode( '|', $terms ); |
575 | | - $terms = str_replace( '/', "\\/", $terms); |
576 | 578 | $max = intval( $contextchars ) + 1; |
577 | 579 | $pat1 = "/(.*)($terms)(.{0,$max})/i"; |
578 | 580 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -190,8 +190,8 @@ |
191 | 191 | * (bug 13756) Don't show the form and navigation links of Special:Newpages if |
192 | 192 | the page is included |
193 | 193 | * When hiding things on WhatLinksHere, generated URLs should hide them too |
194 | | -* Properly escape search terms with forward slashes so they appear highlighted |
195 | | - in search results. |
| 194 | +* Properly escape search terms with regex chars so they appear highlighted in |
| 195 | + search results |
196 | 196 | |
197 | 197 | |
198 | 198 | === API changes in 1.13 === |