From: Mark A. Hershberger Date: Wed, 6 Apr 2011 00:56:22 +0000 (+0000) Subject: Patch from Bug #28406: X-Git-Tag: 1.31.0-rc.0~31002 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=46cf8879ea5c81a8dfd4d314c8c9a1d40f3c3ae7;p=lhc%2Fweb%2Fwiklou.git Patch from Bug #28406: # the digitClass join versions were inverted: for a maxLength > 1 it should be (|||), not [] # the regexp escape for digits in the ts_number_transform_table was a bit, er, strange. Although it worked, I think my version is more common. # most important: As recommended in http://en.wikipedia.org/wiki/Percent_sign, there may be some whitespaces between the number and the "%". See also Bug #15422 for that, I'm not sure wheter it's included there. I didn't include the “non-breaking space is part of \s” bit since I didn't want to mess up browser bug work-arounds --- diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index b862f5c88a..3f9dc6752a 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -740,17 +740,16 @@ window.ts_initTransformTable = function() { for ( var digit in ts_number_transform_table ) { // Escape regex metacharacters digits.push( - digit.replace( /[\\\\$\*\+\?\.\(\)\|\{\}\[\]\-]/, - function( s ) { return '\\' + s; } ) + digit.replace( /([{}()|.?*+^$\[\]\\-])/g, "\\$1" ) ); if ( digit.length > maxDigitLength ) { maxDigitLength = digit.length; } } if ( maxDigitLength > 1 ) { - var digitClass = '[' + digits.join( '', digits ) + ']'; + var digitClass = '(' + digits.join( '|' ) + ')'; } else { - var digitClass = '(' + digits.join( '|', digits ) + ')'; + var digitClass = '[' + digits.join( '' ) + ']'; } } @@ -760,7 +759,7 @@ window.ts_initTransformTable = function() { "^(" + "[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?" + // Fortran-style scientific "|" + - "[-+\u2212]?" + digitClass + "+%?" + // Generic localised + "[-+\u2212]?" + digitClass + "+[\s\xa0]*%?" + // Generic localised ")$", "i" ); };