From ff674ad8e70047f6ef927b0028728a813320ad2a Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Wed, 3 Sep 2008 13:45:10 +0000 Subject: [PATCH] Use ECMAScript standard, section 9.3, to decide what's a number r40348 was kind of broken, in terms of considering strings like "e" to be numbers. The version before that would also act incorrectly for strings like ".". --- skins/common/wikibits.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 9a5dc13fdc..fa6fe83766 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -616,7 +616,11 @@ function ts_resortTable(lnk) { // pound dollar euro yen currency cents else if (itm.match(/(^[\u00a3$\u20ac\u00a4\u00a5]|\u00a2$)/)) sortfn = ts_sort_currency; - else if (itm.match(/^[\d.,eE+-]+\%?$/)) + // We allow a trailing percent sign, which we just strip. This works fine + // if percents and regular numbers aren't being mixed. + else if (itm.match(/^[+-]?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9]+)?\%?$/) || + itm.match(/^[+-]?\.[0-9]+([eE][+-]?[0-9]+)?\%?$/) || + itm.match(/^0[xX][0-9a-fA-F]+$/)) sortfn = ts_sort_numeric; var reverse = (span.getAttribute("sortdir") == 'down'); -- 2.20.1