mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09: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
|
@ -147,7 +147,7 @@ void SourceHighlighterClient::highlighter_did_set_folding_regions(Vector<Syntax:
|
|||
document().set_folding_regions(move(folding_regions));
|
||||
}
|
||||
|
||||
String highlight_source(URL::URL const& url, URL::URL const& base_url, String const& source, Syntax::Language language, HighlightOutputMode mode)
|
||||
String highlight_source(Optional<URL::URL> const& url, URL::URL const& base_url, String const& source, Syntax::Language language, HighlightOutputMode mode)
|
||||
{
|
||||
SourceHighlighterClient highlighter_client { source, language };
|
||||
return highlighter_client.to_html_string(url, base_url, mode);
|
||||
|
@ -268,7 +268,7 @@ StringView SourceHighlighterClient::class_for_token(u64 token_type) const
|
|||
}
|
||||
}
|
||||
|
||||
String SourceHighlighterClient::to_html_string(URL::URL const& url, URL::URL const& base_url, HighlightOutputMode mode) const
|
||||
String SourceHighlighterClient::to_html_string(Optional<URL::URL> const& url, URL::URL const& base_url, HighlightOutputMode mode) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -302,7 +302,11 @@ String SourceHighlighterClient::to_html_string(URL::URL const& url, URL::URL con
|
|||
<head>
|
||||
<meta name="color-scheme" content="dark light">)~~~"sv);
|
||||
|
||||
builder.appendff("<title>View Source - {}</title>", escape_html_entities(url.serialize_for_display()));
|
||||
if (url.has_value())
|
||||
builder.appendff("<title>View Source - {}</title>", escape_html_entities(url->serialize_for_display()));
|
||||
else
|
||||
builder.append("<title>View Source</title>"sv);
|
||||
|
||||
builder.appendff("<style type=\"text/css\">{}</style>", HTML_HIGHLIGHTER_STYLE);
|
||||
builder.append(R"~~~(
|
||||
</head>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue