author | Arthur Chen <arthur.chen@mozilla.com> |
Fri, 12 Apr 2013 08:20:31 -0400 | |
changeset 128583 | 9ee76e6261e60356c1b43d2957b08e7a6b964bd9 |
parent 128582 | 0614d7cadd7630d2a6982b68f8daa6b8ef65cbbe |
child 128584 | 9461d02ac47d062d2db99930313fa1b7725ee1b5 |
push id | 24532 |
push user | ryanvm@gmail.com |
push date | Fri, 12 Apr 2013 19:06:49 +0000 |
treeherder | mozilla-central@2aff2d574a1e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gwagner |
bugs | 832946 |
milestone | 23.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/b2g/components/TelURIParser.jsm +++ b/b2g/components/TelURIParser.jsm @@ -6,21 +6,16 @@ this.EXPORTED_SYMBOLS = ["TelURIParser"]; /** * Singleton providing functionality for parsing tel: and sms: URIs */ this.TelURIParser = { parseURI: function(scheme, uri) { - // Ignore MWI and USSD codes. See 794034. - if (uri.indexOf('*') != -1 || uri.indexOf('#') != -1) { - return null; - } - // https://www.ietf.org/rfc/rfc2806.txt let subscriber = uri.slice((scheme + ':').length); if (!subscriber.length) { return null; } let number = ''; @@ -109,12 +104,17 @@ this.TelURIParser = { if (subscriber.substring(pos, pos + 15) == ';phone-context=') { pos += 15; // global-network-prefix | local-network-prefix | private-prefi number = subscriber.substring(pos, subscriber.length) + number; } } + // Ignore MWI and USSD codes. See 794034. + if (number.match(/[#\*]/) && !number.match(/^[#\*]\d+$/)) { + return null; + } + return number || null; } };
new file mode 100644 --- /dev/null +++ b/b2g/components/test/unit/test_bug832946.js @@ -0,0 +1,18 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function run_test() { + Components.utils.import("resource:///modules/TelURIParser.jsm") + + // blocked numbers + do_check_eq(TelURIParser.parseURI('tel', 'tel:#1234*'), null); + do_check_eq(TelURIParser.parseURI('tel', 'tel:*1234#'), null); + do_check_eq(TelURIParser.parseURI('tel', 'tel:*1234*'), null); + do_check_eq(TelURIParser.parseURI('tel', 'tel:#1234#'), null); + do_check_eq(TelURIParser.parseURI('tel', 'tel:*#*#7780#*#*'), null); + do_check_eq(TelURIParser.parseURI('tel', 'tel:*1234AB'), null); + + // white list + do_check_eq(TelURIParser.parseURI('tel', 'tel:*1234'), '*1234'); + do_check_eq(TelURIParser.parseURI('tel', 'tel:#1234'), '#1234'); +}