diff --git a/Base/home/anon/www/data-url.html b/Base/home/anon/www/data-url.html new file mode 100644 index 00000000000..0f6e4988d01 --- /dev/null +++ b/Base/home/anon/www/data-url.html @@ -0,0 +1,8 @@ + + + + +
+ + + diff --git a/Libraries/LibWeb/ResourceLoader.cpp b/Libraries/LibWeb/ResourceLoader.cpp index ed013daeaea..a26ab277467 100644 --- a/Libraries/LibWeb/ResourceLoader.cpp +++ b/Libraries/LibWeb/ResourceLoader.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -72,6 +73,21 @@ void ResourceLoader::load(const URL& url, Function succ return; } + if (url.protocol() == "data") { + dbg() << "ResourceLoader loading a data URL with mime-type: '" << url.data_mime_type() << "', base64=" << url.data_payload_is_base64() << ", payload='" << url.data_payload() << "'"; + + ByteBuffer data; + if (url.data_payload_is_base64()) + data = decode_base64(url.data_payload()); + else + data = url.data_payload().to_byte_buffer(); + + deferred_invoke([data = move(data), success_callback = move(success_callback)](auto&) { + success_callback(data); + }); + return; + } + if (url.protocol() == "file") { auto f = Core::File::construct(); f->set_filename(url.path());