Bug 873511 - Correctly parse 'tel:' links that contain whitespaces. r=fabrice

This commit is contained in:
Mihai Cirlanaru 2013-07-26 11:20:17 -04:00
parent d60bbc5058
commit 0f836c538b
2 changed files with 6 additions and 3 deletions

View File

@ -12,7 +12,7 @@ this.EXPORTED_SYMBOLS = ["TelURIParser"];
this.TelURIParser = {
parseURI: function(scheme, uri) {
// https://www.ietf.org/rfc/rfc2806.txt
let subscriber = uri.slice((scheme + ':').length);
let subscriber = decodeURIComponent(uri.slice((scheme + ':').length));
if (!subscriber.length) {
return null;
@ -23,7 +23,7 @@ this.TelURIParser = {
let len = subscriber.length;
// visual-separator
let visualSeparator = [ '-', '.', '(', ')' ];
let visualSeparator = [ ' ', '-', '.', '(', ')' ];
let digits = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
let dtmfDigits = [ '*', '#', 'A', 'B', 'C', 'D' ];
let pauseCharacter = [ 'p', 'w' ];

View File

@ -5,7 +5,10 @@ function run_test() {
Components.utils.import("resource:///modules/TelURIParser.jsm")
// global-phone-number
do_check_eq(TelURIParser.parseURI('tel', 'tel:+1234'), '+1234');
do_check_eq(TelURIParser.parseURI('tel', 'tel:+1234'), '+1234');
// global-phone-number => white space separator
do_check_eq(TelURIParser.parseURI('tel', 'tel:+123 456 789'), '+123 456 789');
// global-phone-number => ignored chars
do_check_eq(TelURIParser.parseURI('tel', 'tel:+1234_123'), '+1234');