зеркало из https://github.com/mozilla/gecko-dev.git
Bug 781693 - Accept ';' as delimiter after 'base64' keyword. r=bz
This commit is contained in:
Родитель
b5f4583c17
Коммит
56de728440
|
@ -163,9 +163,16 @@ nsDataHandler::ParseURI(nsCString& spec,
|
|||
|
||||
// determine if the data is base64 encoded.
|
||||
char *base64 = PL_strcasestr(buffer, BASE64_EXTENSION);
|
||||
if (base64 && *(base64 + strlen(BASE64_EXTENSION))==0) {
|
||||
isBase64 = true;
|
||||
*base64 = '\0';
|
||||
if (base64) {
|
||||
char *beyond = base64 + strlen(BASE64_EXTENSION);
|
||||
// per the RFC 2397 grammar, "base64" MUST be followed by a comma
|
||||
// previously substituted by '\0', but we also allow it in between
|
||||
// parameters so a subsequent ";" is ok as well (this deals with
|
||||
// *broken* data URIs, see bug 781693 for an example)
|
||||
if (*beyond == '\0' || *beyond == ';') {
|
||||
isBase64 = true;
|
||||
*base64 = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (comma == buffer) {
|
||||
|
|
|
@ -11,13 +11,16 @@ const Cr = Components.results;
|
|||
var urls = [
|
||||
["data:,foo", "text/plain", "foo"],
|
||||
["data:application/octet-stream,foo bar", "application/octet-stream", "foobar"],
|
||||
["data:application/octet-stream;base64=y,foobar", "application/octet-stream", "foobar"],
|
||||
["data:application/octet-stream,foo%20bar", "application/octet-stream", "foo bar"],
|
||||
["data:application/xhtml+xml,foo bar", "application/xhtml+xml", "foo bar"],
|
||||
["data:application/xhtml+xml,foo%20bar", "application/xhtml+xml", "foo bar"],
|
||||
["data:text/plain,foo%00 bar", "text/plain", "foo\x00 bar"],
|
||||
["data:text/plain;base64,Zm9 vI%20GJ%0Dhc%0Ag==", "text/plain", "foo bar"],
|
||||
["DATA:TEXT/PLAIN;BASE64,Zm9 vI%20GJ%0Dhc%0Ag==", "text/plain", "foo bar"]
|
||||
["DATA:TEXT/PLAIN;BASE64,Zm9 vI%20GJ%0Dhc%0Ag==", "text/plain", "foo bar"],
|
||||
// Bug 774240
|
||||
["data:application/octet-stream;base64=y,foobar", "application/octet-stream", "foobar"],
|
||||
// Bug 781693
|
||||
["data:text/plain;base64;x=y,dGVzdA==", "text/plain", "test"]
|
||||
];
|
||||
|
||||
function run_test() {
|
||||
|
@ -31,7 +34,7 @@ function run_test() {
|
|||
|
||||
/* read completed successfully. now compare the data. */
|
||||
if (data != urls[idx][2])
|
||||
do_throw("Stream contents do not match with direct read!");
|
||||
do_throw("Stream contents do not match with direct read! Is <" + data + ">, should be <" + urls[idx][2] + ">");
|
||||
do_test_finished();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче