/* * Copyright (c) 2024, Luke Wilde * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include namespace Web::ContentSecurityPolicy::Directives { GC_DEFINE_ALLOCATOR(FormActionDirective); FormActionDirective::FormActionDirective(String name, Vector value) : Directive(move(name), move(value)) { } Directive::Result FormActionDirective::pre_navigation_check(GC::Ref request, NavigationType navigation_type, GC::Ref policy) const { // 1. Assert: policy is unused in this algorithm. // FIXME: File spec issue, because this is not the case. The policy is required to resolve 'self'. // 2. If navigation type is "form-submission": if (navigation_type == NavigationType::FormSubmission) { // 1. If the result of executing § 6.7.2.5 Does request match source list? on request, this directive’s value, // and a policy, is "Does Not Match", return "Blocked". if (does_request_match_source_list(request, value(), policy) == MatchResult::DoesNotMatch) return Result::Blocked; } // 3. Return "Allowed". return Result::Allowed; } }