mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb/CSP: Implement URL matching algorithms
These are used by all the *-src attributes, to check if a given URL, origin and redirect count matches a source list entry specified in the *-src attribute's values, if it's allowed to.
This commit is contained in:
parent
38f80913a4
commit
1edf7a8aa2
Notes:
github-actions[bot]
2025-06-30 22:25:59 +00:00
Author: https://github.com/Lubrsi
Commit: 1edf7a8aa2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4367
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/shannonbooth
2 changed files with 364 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <AK/StringView.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibURL/Forward.h>
|
||||
#include <LibWeb/ContentSecurityPolicy/Directives/Directive.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
|
@ -18,10 +19,18 @@ enum class ShouldExecute {
|
|||
Yes,
|
||||
};
|
||||
|
||||
enum class MatchResult {
|
||||
DoesNotMatch,
|
||||
Matches,
|
||||
};
|
||||
|
||||
[[nodiscard]] Optional<FlyString> get_the_effective_directive_for_request(GC::Ref<Fetch::Infrastructure::Request const> request);
|
||||
[[nodiscard]] Vector<StringView> get_fetch_directive_fallback_list(Optional<FlyString> directive_name);
|
||||
[[nodiscard]] ShouldExecute should_fetch_directive_execute(Optional<FlyString> effective_directive_name, FlyString const& directive_name, GC::Ref<Policy const> policy);
|
||||
|
||||
[[nodiscard]] FlyString get_the_effective_directive_for_inline_checks(Directive::InlineType type);
|
||||
|
||||
[[nodiscard]] MatchResult does_url_match_expression_in_origin_with_redirect_count(URL::URL const& url, String const& expression, URL::Origin const& origin, u8 redirect_count);
|
||||
[[nodiscard]] MatchResult does_url_match_source_list_in_origin_with_redirect_count(URL::URL const& url, Vector<String> const& source_list, URL::Origin const& origin, u8 redirect_count);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue