Bug 1288482 - Backout bug 1042347. r=mcmanus

MozReview-Commit-ID: J3LmMfQ854V
This commit is contained in:
Valentin Gosu 2016-07-24 23:35:12 +02:00
parent af1323ff34
commit c6165ca8ee
5 changed files with 46 additions and 32 deletions

View File

@ -239,7 +239,7 @@ net_CoalesceDirs(netCoalesceFlags flags, char* path)
*/
char *fwdPtr = path;
char *urlPtr = path;
char *endPath = path;
char *lastslash = path;
uint32_t traversal = 0;
uint32_t special_ftp_len = 0;
@ -256,18 +256,34 @@ net_CoalesceDirs(netCoalesceFlags flags, char* path)
special_ftp_len = 2;
}
/* find the end of the path - places the cursor on \0, ? or # */
for(; (*fwdPtr != '\0') &&
(*fwdPtr != '?') &&
/* find the last slash before # or ? */
for(; (*fwdPtr != '\0') &&
(*fwdPtr != '?') &&
(*fwdPtr != '#'); ++fwdPtr)
{
}
endPath = fwdPtr;
/* found nothing, but go back one only */
/* if there is something to go back to */
if (fwdPtr != path && *fwdPtr == '\0')
{
--fwdPtr;
}
/* search the slash */
for(; (fwdPtr != path) &&
(*fwdPtr != '/'); --fwdPtr)
{
}
lastslash = fwdPtr;
fwdPtr = path;
/* replace all %2E or %2e with . in the path */
for(; fwdPtr != endPath; ++fwdPtr)
/* but stop at lastchar if non null */
for(; (*fwdPtr != '\0') &&
(*fwdPtr != '?') &&
(*fwdPtr != '#') &&
(*lastslash == '\0' || fwdPtr != lastslash); ++fwdPtr)
{
if (*fwdPtr == '%' && *(fwdPtr+1) == '2' &&
(*(fwdPtr+2) == 'E' || *(fwdPtr+2) == 'e'))

View File

@ -301,32 +301,6 @@ add_test(function test_hugeStringThrows()
run_next_test();
});
add_test(function test_pathPercentEncodedDot()
{
var url = stringToURL("http://example.com/%2eX/X%2e/%2eX");
do_check_eq(url.spec, "http://example.com/.X/X./.X");
url = stringToURL("http://example.com/hello/%2e%2E/%2e");
do_check_eq(url.spec, "http://example.com/");
url = stringToURL("http://example.com/hello/%2e%2E/%");
do_check_eq(url.spec, "http://example.com/%");
url = stringToURL("http://example.com/hello/%2e%2E/%2");
do_check_eq(url.spec, "http://example.com/%2");
url = stringToURL("http://example.com/hello/%2e%2E/%#");
do_check_eq(url.spec, "http://example.com/%#");
url = stringToURL("http://example.com/hello/%2e%2E/%2?");
do_check_eq(url.spec, "http://example.com/%2?");
url = stringToURL("http://example.com/hello/%2e/");
do_check_eq(url.spec, "http://example.com/hello/");
run_next_test();
});
add_test(function test_filterWhitespace()
{
var url = stringToURL(" \r\n\th\nt\rt\tp://ex\r\n\tample.com/path\r\n\t/\r\n\tto the/fil\r\n\te.e\r\n\txt?que\r\n\try#ha\r\n\tsh \r\n\t ");

View File

@ -132,6 +132,9 @@
[Parsing: <http://www.google.com/foo?bar=baz# »> against <about:blank>]
expected: FAIL
[Parsing: <http://example.com/foo/%2e> against <about:blank>]
expected: FAIL
[Parsing: <data:test# »> against <about:blank>]
expected: FAIL
@ -435,3 +438,8 @@
[Parsing: <http:> against <https://example.org/foo/bar>]
expected: FAIL
[Parsing: <http://example.com/foo/%2e%2> against <about:blank>]
expected: FAIL
[Parsing: <http://example.com/foo/%2e./%2e%2e/.%2e/%2e.bar> against <about:blank>]
expected: FAIL

View File

@ -123,6 +123,9 @@
[Parsing: <file://test> against <file:///tmp/mock/path>]
expected: FAIL
[Parsing: <http://example.com/foo/%2e> against <about:blank>]
expected: FAIL
[Parsing: <data:test# »> against <about:blank>]
expected: FAIL
@ -444,3 +447,8 @@
[Parsing: <http:> against <https://example.org/foo/bar>]
expected: FAIL
[Parsing: <http://example.com/foo/%2e%2> against <about:blank>]
expected: FAIL
[Parsing: <http://example.com/foo/%2e./%2e%2e/.%2e/%2e.bar> against <about:blank>]
expected: FAIL

View File

@ -75,6 +75,9 @@
[Parsing: <http://www.google.com/foo?bar=baz# »> against <about:blank>]
expected: FAIL
[Parsing: <http://example.com/foo/%2e> against <about:blank>]
expected: FAIL
[Parsing: <data:test# »> against <about:blank>]
expected: FAIL
@ -279,3 +282,8 @@
[Parsing: <http://www/foo%2Ehtml> against <about:blank>]
expected: FAIL
[Parsing: <http://example.com/foo/%2e%2> against <about:blank>]
expected: FAIL
[Parsing: <http://example.com/foo/%2e./%2e%2e/.%2e/%2e.bar> against <about:blank>]
expected: FAIL