mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-25 19:51:59 +00:00
LibWebView: Handle missing URL for view source
Instead of potentially passing through an invalid URL.
This commit is contained in:
parent
f857c6a6e6
commit
2827374edc
Notes:
github-actions[bot]
2025-03-04 21:26:39 +00:00
Author: https://github.com/shannonbooth
Commit: 2827374edc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3668
Reviewed-by: https://github.com/trflynn89
3 changed files with 12 additions and 7 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <LibCore/File.h>
|
||||
#include <LibCore/Resource.h>
|
||||
#include <LibJS/MarkupGenerator.h>
|
||||
#include <LibURL/Parser.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWebView/Application.h>
|
||||
|
@ -97,8 +98,8 @@ InspectorClient::InspectorClient(ViewImplementation& content_web_view, ViewImple
|
|||
m_inspector_web_view.run_javascript(MUST(builder.to_string()));
|
||||
};
|
||||
|
||||
m_content_web_view.on_received_style_sheet_source = [this](Web::CSS::StyleSheetIdentifier const& identifier, auto const& base_url, String const& source) {
|
||||
auto html = highlight_source(identifier.url.value_or({}), base_url, source, Syntax::Language::CSS, HighlightOutputMode::SourceOnly);
|
||||
m_content_web_view.on_received_style_sheet_source = [this](Web::CSS::StyleSheetIdentifier const& identifier, URL::URL const& base_url, String const& source) {
|
||||
auto html = highlight_source(URL::Parser::basic_parse(identifier.url.value_or({})), base_url, source, Syntax::Language::CSS, HighlightOutputMode::SourceOnly);
|
||||
auto script = MUST(String::formatted("inspector.setStyleSheetSource({}, \"{}\");",
|
||||
style_sheet_identifier_to_json(identifier),
|
||||
MUST(encode_base64(html.bytes()))));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue