LibURL+LibWeb: Add a helper to check if a URL is a WebUI URL
Let's not have to know off-hand that we need to update Environments.cpp when adding a new WebUI. It's more obvious just below where we define the URLs.
This commit is contained in:
parent
39d7abee2f
commit
2f3199adbf
2 changed files with 8 additions and 4 deletions
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/CopyOnWrite.h>
|
||||
#include <AK/GenericShorthands.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
|
|
@ -222,6 +223,11 @@ inline URL about_processes() { return URL::about("processes"_string); }
|
|||
inline URL about_settings() { return URL::about("settings"_string); }
|
||||
inline URL about_version() { return URL::about("version"_string); }
|
||||
|
||||
inline bool is_webui_url(URL const& url)
|
||||
{
|
||||
return first_is_one_of(url, about_processes(), about_settings());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
|
|||
|
|
@ -283,10 +283,8 @@ bool is_scripting_enabled(EnvironmentSettingsObject const& settings)
|
|||
// The user has not disabled scripting for realm at this time. (User agents may provide users with the option to disable scripting globally, or in a finer-grained manner, e.g., on a per-origin basis, down to the level of individual realms.)
|
||||
auto const& document = as<HTML::Window>(settings.global_object()).associated_document();
|
||||
|
||||
// NB: about:settings and about:processes are internal pages using javascript, so we do not consider user configuration for these pages.
|
||||
if (document.url() != URL::about_settings()
|
||||
&& document.url() != URL::about_processes()
|
||||
&& !document.page().is_scripting_enabled())
|
||||
// NB: WebUI pages are internal pages requiring javascript, so we do not consider user configuration for these.
|
||||
if (!document.page().is_scripting_enabled() && !URL::is_webui_url(document.url()))
|
||||
return false;
|
||||
|
||||
// Either settings's global object is not a Window object, or settings's global object's associated Document's active sandboxing flag set does not have its sandboxed scripts browsing context flag set.
|
||||
|
|
|
|||
Loading…
Reference in a new issue