r96625 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96624‎ | r96625 | r96626 >
Date:22:28, 8 September 2011
Author:brion
Status:ok
Tags:
Comment:
MFT r90092, r94702 - jquery.highlightText.js fixes for non-ASCII chars in Vector search suggestions (bug 29371)
Modified paths:
  • /branches/wmf/1.17wmf1/resources/jquery/jquery.highlightText.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.17wmf1/resources/jquery/jquery.highlightText.js
@@ -21,10 +21,12 @@
2222 // if this is a text node
2323 if ( node.nodeType == 3 ) {
2424 // TODO - need to be smarter about the character matching here.
25 - // non latin characters can make regex think a new word has begun.
26 - // look for an occurence of our pattern and store the starting position
27 - var pos = node.data.search( new RegExp( "\\b" + $.escapeRE( pat ), "i" ) );
28 - if ( pos >= 0 ) {
 25+ // non latin characters can make regex think a new word has begun: do not use \b
 26+ // http://stackoverflow.com/questions/3787072/regex-wordwrap-with-utf8-characters-in-js
 27+ // look for an occurence of our pattern and store the starting position
 28+ var match = node.data.match( new RegExp( "(^|\\s)" + $.escapeRE( pat ), "i" ) );
 29+ if ( match ) {
 30+ var pos = match.index + match[1].length; // include length of any matched spaces
2931 // create the span wrapper for the matched text
3032 var spannode = document.createElement( 'span' );
3133 spannode.className = 'highlight';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90092fix for bug29371 . regex wordwrap with UTF8: do not use \b metacharacter. The...wikinaut21:42, 14 June 2011
r94702Fix a regression in search highlighting from r90092...brion22:42, 16 August 2011
r96623MFT r90092, r94702 - jquery.highlightText.js fixes for non-ASCII chars in Vec...brion22:27, 8 September 2011

Status & tagging log