moebius#131: URL parser - stop preserving empty passwords

https://github.com/MoonchildProductions/moebius/issues/131
This commit is contained in:
janekptacijarabaci 2018-04-15 08:09:17 +02:00 committed by Roy Tam
commit de0621cc7e
4 changed files with 31 additions and 5 deletions

View file

@ -472,3 +472,23 @@ add_test(function test_invalidHostChars() {
// hostname separators, so there is no way to set them and fail.
run_next_test();
});
add_test(function test_emptyPassword() {
var url = stringToURL("http://a:@example.com");
do_check_eq(url.spec, "http://a@example.com/");
url.password = "pp";
do_check_eq(url.spec, "http://a:pp@example.com/");
url.password = "";
do_check_eq(url.spec, "http://a@example.com/");
url.userPass = "xxx:";
do_check_eq(url.spec, "http://xxx@example.com/");
url.password = "zzzz";
do_check_eq(url.spec, "http://xxx:zzzz@example.com/");
url.userPass = "xxxxx:yyyyyy";
do_check_eq(url.spec, "http://xxxxx:yyyyyy@example.com/");
url.userPass = "z:";
do_check_eq(url.spec, "http://z@example.com/");
url.password = "ppppppppppp";
do_check_eq(url.spec, "http://z:ppppppppppp@example.com/");
run_next_test();
});