Data URLs: parse the whole URL, not just the path.

The RFC for Data URLs specifies a nonstandard format, and because of
this it doesn't support queries and fragments. This allows the use of
the # and ? characters in the URL data. We didn't handle this properly,
which would lead to truncated data.
This commit is contained in:
Adrien Destugues
2014-08-01 09:38:28 +02:00
parent eec762686b
commit 6bd0ac9489
+9 -1
View File
@@ -39,8 +39,16 @@ BDataRequest::_ProtocolLoop()
ssize_t length;
bool isBase64 = false;
// The RFC has examples where some characters are URL-Encoded.
fUrl.UrlDecode(true);
BString data = fUrl.Path();
// The RFC says this uses a nonstandard scheme, so the path, query and
// fragment are a bit nonsensical. It would be nice to handle them, but
// some software (eg. WebKit) relies on data URIs with embedded "#" char
// in the data...
BString data = fUrl.UrlString();
data.Remove(0, 5); // remove "data:"
int separatorPosition = data.FindFirst(',');
if (fListener != NULL)