From: Aryeh Gregor Date: Wed, 3 Sep 2008 13:45:10 +0000 (+0000) Subject: Use ECMAScript standard, section 9.3, to decide what's a number X-Git-Tag: 1.31.0-rc.0~45511 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28%27votes%27%2C%20votes=%27waiting%27%29%20%7D%7D?a=commitdiff_plain;h=ff674ad8e70047f6ef927b0028728a813320ad2a;p=lhc%2Fweb%2Fwiklou.git 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 ".". --- 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');