From ec83555b872b89e1226bc8dd2c8170292058f847 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 7 Jun 2020 18:23:33 +0200 Subject: [PATCH] AK: Don't try to complete relative data: URLs --- AK/URL.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/AK/URL.cpp b/AK/URL.cpp index 24f671e6f1..91e8094ab5 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -47,6 +47,9 @@ static inline bool is_digit(char ch) bool URL::parse(const StringView& string) { + if (string.is_null()) + return false; + enum class State { InProtocol, InHostname, @@ -291,10 +294,16 @@ String URL::to_string() const URL URL::complete_url(const String& string) const { + if (!is_valid()) + return {}; + URL url(string); if (url.is_valid()) return url; + if (protocol() == "data") + return {}; + if (string.starts_with("//")) { URL url(String::format("%s:%s", m_protocol.characters(), string.characters())); if (url.is_valid())