mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-25 01:01:52 +00:00
Bug 1163028 - stop escaping [ and ] in toFileURI r=yoric
This commit is contained in:
parent
e96a491a5d
commit
39e3e75879
@ -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'
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user