mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 18:19:03 +00:00
LibWeb: Implement Content Security Policy directive expression parser
This follows the implementation method that was used for the implementation of ISO8601 parsing for Temporal in LibJS. Doing it this way allows us to have state transactions, and thus pick out individual parse nodes that the specification steps want to use.
This commit is contained in:
parent
050f984625
commit
38f80913a4
Notes:
github-actions[bot]
2025-06-30 22:26:05 +00:00
Author: https://github.com/Lubrsi
Commit: 38f80913a4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4367
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/shannonbooth
3 changed files with 475 additions and 0 deletions
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace Web::ContentSecurityPolicy::Directives {
|
||||
|
||||
struct SourceExpressionParseResult {
|
||||
Optional<StringView> scheme_part;
|
||||
Optional<StringView> host_part;
|
||||
Optional<StringView> port_part;
|
||||
Optional<StringView> path_part;
|
||||
Optional<StringView> keyword_source;
|
||||
Optional<StringView> base64_value;
|
||||
Optional<StringView> hash_algorithm;
|
||||
};
|
||||
|
||||
enum class Production {
|
||||
SchemeSource,
|
||||
HostSource,
|
||||
KeywordSource,
|
||||
NonceSource,
|
||||
HashSource,
|
||||
};
|
||||
|
||||
Optional<SourceExpressionParseResult> parse_source_expression(Production, StringView);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue