mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fixing bug 451613. URL parsing treats leading whitespace inconsistently. r=jst@mozilla.org
This commit is contained in:
parent
71c558dbe8
commit
2fb50e2eb6
@ -93,12 +93,14 @@ nsBaseURLParser::ParseURL(const char *spec, PRInt32 specLen,
|
||||
const char *colon = nsnull;
|
||||
const char *slash = nsnull;
|
||||
const char *p;
|
||||
PRUint32 offset = 0;
|
||||
PRInt32 len = specLen;
|
||||
for (p = spec; len && *p && !colon && !slash; ++p, --len) {
|
||||
// skip leading whitespace and control characters
|
||||
if (*p > '\0' && *p <= ' ') {
|
||||
// skip leading whitespace
|
||||
if (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') {
|
||||
spec++;
|
||||
specLen--;
|
||||
offset++;
|
||||
continue;
|
||||
}
|
||||
switch (*p) {
|
||||
@ -124,7 +126,7 @@ nsBaseURLParser::ParseURL(const char *spec, PRInt32 specLen,
|
||||
if (colon && stop && colon > stop)
|
||||
colon = nsnull;
|
||||
|
||||
// if the spec only contained whitespace or control characters...
|
||||
// if the spec only contained whitespace ...
|
||||
if (specLen == 0) {
|
||||
SET_RESULT(scheme, 0, -1);
|
||||
SET_RESULT(authority, 0, 0);
|
||||
@ -151,10 +153,11 @@ nsBaseURLParser::ParseURL(const char *spec, PRInt32 specLen,
|
||||
NS_WARNING("malformed uri");
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
}
|
||||
SET_RESULT(scheme, 0, colon - spec);
|
||||
SET_RESULT(scheme, offset, colon - spec);
|
||||
if (authorityLen || pathLen) {
|
||||
PRUint32 offset = colon + 1 - spec;
|
||||
ParseAfterScheme(colon + 1, specLen - offset,
|
||||
PRUint32 schemeLen = colon + 1 - spec;
|
||||
offset += schemeLen;
|
||||
ParseAfterScheme(colon + 1, specLen - schemeLen,
|
||||
authorityPos, authorityLen,
|
||||
pathPos, pathLen);
|
||||
OFFSET_RESULT(authority, offset);
|
||||
@ -181,6 +184,8 @@ nsBaseURLParser::ParseURL(const char *spec, PRInt32 specLen,
|
||||
ParseAfterScheme(spec, specLen,
|
||||
authorityPos, authorityLen,
|
||||
pathPos, pathLen);
|
||||
OFFSET_RESULT(authority, offset);
|
||||
OFFSET_RESULT(path, offset);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user