From 46cf8879ea5c81a8dfd4d314c8c9a1d40f3c3ae7 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Wed, 6 Apr 2011 00:56:22 +0000 Subject: [PATCH] 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. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- skins/common/wikibits.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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" ); }; -- 2.20.1