From 6bd0ac94896d11bc915cd16b0104583a32e6f7e2 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 30 Jul 2014 15:52:46 +0200 Subject: [PATCH] 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. --- src/kits/network/libnetapi/DataRequest.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/kits/network/libnetapi/DataRequest.cpp b/src/kits/network/libnetapi/DataRequest.cpp index 40c8c251ff..c650c73965 100644 --- a/src/kits/network/libnetapi/DataRequest.cpp +++ b/src/kits/network/libnetapi/DataRequest.cpp @@ -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)