mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
AK: Consider more URLs invalid
Not just http or https. This fixes "foo" being recognized as a valid URL with protocol "foo", empty host and empty path.
This commit is contained in:
parent
50c139e61c
commit
5a96a6565b
Notes:
sideshowbarker
2024-07-19 07:28:58 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/5a96a6565b1 Pull-request: https://github.com/SerenityOS/serenity/pull/1866
1 changed files with 6 additions and 4 deletions
10
AK/URL.cpp
10
AK/URL.cpp
|
@ -169,6 +169,8 @@ bool URL::parse(const StringView& string)
|
||||||
m_host = String::copy(buffer);
|
m_host = String::copy(buffer);
|
||||||
m_path = "/";
|
m_path = "/";
|
||||||
}
|
}
|
||||||
|
if (state == State::InProtocol)
|
||||||
|
return false;
|
||||||
if (state == State::InPath)
|
if (state == State::InPath)
|
||||||
m_path = String::copy(buffer);
|
m_path = String::copy(buffer);
|
||||||
if (state == State::InQuery)
|
if (state == State::InQuery)
|
||||||
|
@ -277,12 +279,12 @@ bool URL::compute_validity() const
|
||||||
// FIXME: This is by no means complete.
|
// FIXME: This is by no means complete.
|
||||||
if (m_protocol.is_empty())
|
if (m_protocol.is_empty())
|
||||||
return false;
|
return false;
|
||||||
if (m_protocol == "http" || m_protocol == "https") {
|
if (m_protocol == "file") {
|
||||||
if (m_host.is_empty())
|
|
||||||
return false;
|
|
||||||
} else if (m_protocol == "file") {
|
|
||||||
if (m_path.is_empty())
|
if (m_path.is_empty())
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
if (m_host.is_empty())
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue