From: Thomas Gries Date: Tue, 14 Jun 2011 21:42:25 +0000 (+0000) Subject: fix for bug29371 . regex wordwrap with UTF8: do not use \b metacharacter. The problem... X-Git-Tag: 1.31.0-rc.0~29530 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=016e0ca1135660e15987046dbb90ab6e4d95b397;p=lhc%2Fweb%2Fwiklou.git fix for bug29371 . regex wordwrap with UTF8: do not use \b metacharacter. The problem is that JavaScript recognizes word boundaries only before/after ASCII letters (and numbers/underscore) --- diff --git a/resources/jquery/jquery.autoEllipsis.js b/resources/jquery/jquery.autoEllipsis.js index 625331046b..7d7268942f 100644 --- a/resources/jquery/jquery.autoEllipsis.js +++ b/resources/jquery/jquery.autoEllipsis.js @@ -5,7 +5,7 @@ // Cache ellipsed substrings for every string-width-position combination var cache = { }; -// Use a seperate cache when match highlighting is enabled +// Use a separate cache when match highlighting is enabled var matchTextCache = { }; $.fn.autoEllipsis = function( options ) { diff --git a/resources/jquery/jquery.highlightText.js b/resources/jquery/jquery.highlightText.js index 7ca29efde2..4bc231c233 100644 --- a/resources/jquery/jquery.highlightText.js +++ b/resources/jquery/jquery.highlightText.js @@ -21,9 +21,10 @@ $.highlightText = { // if this is a text node if ( node.nodeType == 3 ) { // TODO - need to be smarter about the character matching here. - // non latin characters can make regex think a new word has begun. - // look for an occurence of our pattern and store the starting position - var pos = node.data.search( new RegExp( "\\b" + $.escapeRE( pat ), "i" ) ); + // non latin characters can make regex think a new word has begun: do not use \b + // http://stackoverflow.com/questions/3787072/regex-wordwrap-with-utf8-characters-in-js + // look for an occurence of our pattern and store the starting position + var pos = node.data.search( new RegExp( "(^|\\s)" + $.escapeRE( pat ), "i" ) ); if ( pos >= 0 ) { // create the span wrapper for the matched text var spannode = document.createElement( 'span' ); diff --git a/resources/jquery/jquery.suggestions.js b/resources/jquery/jquery.suggestions.js index d3f294fc30..90cf53b2b0 100644 --- a/resources/jquery/jquery.suggestions.js +++ b/resources/jquery/jquery.suggestions.js @@ -229,7 +229,7 @@ $.suggestions = { } else { result = selected.prev(); if ( selected.length == 0 ) { - // we are at the begginning, so lets jump to the last item + // we are at the beginning, so lets jump to the last item if ( context.data.$container.find( '.suggestions-special' ).html() != "" ) { result = context.data.$container.find( '.suggestions-special' ); } else {