Bug 1163028 - stop escaping [ and ] in toFileURI r=yoric

This commit is contained in:
Valentin Gosu 2015-11-02 13:54:59 +01:00
Родитель e96a491a5d
Коммит 39e3e75879
3 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -165,7 +165,10 @@ exports.split = split;
// The case of %3b is designed to match Services.io, but fundamentally doesn't matter.
var toFileURIExtraEncodings = {';': '%3b', '?': '%3F', '#': '%23'};
var toFileURI = function toFileURI(path) {
let uri = encodeURI(this.normalize(path));
// Per https://url.spec.whatwg.org we should not encode [] in the path
let dontNeedEscaping = {'%5B': '[', '%5D': ']'};
let uri = encodeURI(this.normalize(path)).replace(/%(5B|5D)/gi,
match => dontNeedEscaping[match]);
// add a prefix, and encodeURI doesn't escape a few characters that we do
// want to escape, so fix that up

Просмотреть файл

@ -310,7 +310,10 @@ var toFileURIExtraEncodings = {';': '%3b', '?': '%3F', '#': '%23'};
var toFileURI = function toFileURI(path) {
// URI-escape forward slashes and convert backward slashes to forward
path = this.normalize(path).replace(/[\\\/]/g, m => (m=='\\')? '/' : '%2F');
let uri = encodeURI(path);
// Per https://url.spec.whatwg.org we should not encode [] in the path
let dontNeedEscaping = {'%5B': '[', '%5D': ']'};
let uri = encodeURI(path).replace(/%(5B|5D)/gi,
match => dontNeedEscaping[match]);
// add a prefix, and encodeURI doesn't escape a few characters that we do
// want to escape, so fix that up

Просмотреть файл

@ -54,7 +54,7 @@ function run_test() {
'/test;+%',
'/test?action=index/',
'/test\ test',
'/punctuation/;,/?:@&=+$-_.!~*\'()"#',
'/punctuation/;,/?:@&=+$-_.!~*\'()[]"#',
'/CasePreserving'
];