mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
AK: Decode data URLs to separate class (and parse like every other URL)
Parsing 'data:' URLs took it's own route. It never set standard URL fields like path, query or fragment (except for scheme) and instead gave us separate methods called `data_payload()`, `data_mime_type()`, and `data_payload_is_base64()`. Because parsing 'data:' didn't use standard fields, running the following JS code: new URL('#a', 'data:text/plain,hello').toString() not only cleared the path as URLParser doesn't check for data from data_payload() function (making the result be 'data:#a'), but it also crashes the program because we forbid having an empty MIME type when we serialize to string. With this change, 'data:' URLs will be parsed like every other URLs. To decode the 'data:' URL contents, one needs to call process_data_url() on a URL, which will return a struct containing MIME type with already decoded data! :^)
This commit is contained in:
parent
f27b9b9563
commit
eb41f0144b
9 changed files with 172 additions and 165 deletions
|
@ -124,7 +124,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
|
|||
window->show();
|
||||
} else if (url.host() == String::from_utf8_short_string("doc"sv)) {
|
||||
auto entry = LexicalPath::basename(url.serialize_path());
|
||||
m_webview->load(URL::create_with_data("text/html", render(entry)));
|
||||
m_webview->load(URL::create_with_data("text/html"sv, render(entry)));
|
||||
} else {
|
||||
dbgln("Invalid spreadsheet action domain '{}'", url.serialized_host().release_value_but_fixme_should_propagate_errors());
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
|
|||
return;
|
||||
|
||||
auto key = static_cast<HelpListModel*>(m_listview->model())->key(index);
|
||||
m_webview->load(URL::create_with_data("text/html", render(key)));
|
||||
m_webview->load(URL::create_with_data("text/html"sv, render(key)));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue