Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / content_security_policy / directives / keyword_sources.lucb

#==============================================================================================
#
#   keyword_sources - KeywordSources: the keyword-source expressions
#
#   DESCRIPTION:
#       Port of Libraries/LibWeb/ContentSecurityPolicy/Directives/KeywordSources.cpp (lines 1-16) with
#       KeywordSources.h's ENUMERATE_KEYWORD_SOURCES. C++ initializes the FlyStrings statically; here
#       content_security_policy_directives_keyword_sources_initialize_strings interns them at run time and
#       web_initialize_strings runs it at startup (DESIGN.md ยง2.6).
#
#       Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
#       SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================

## Whether content_security_policy_directives_keyword_sources_initialize_strings has run.
var content_security_policy_directives_keyword_sources_strings_initialized: bool

## Ported from Libraries/LibWeb/ContentSecurityPolicy/Directives/KeywordSources.cpp:11 the definitions of
## Web::ContentSecurityPolicy::Directives::KeywordSources's FlyStrings (`FlyString name = value##_fly_string;` for each ENUMERATE_KEYWORD_SOURCES entry).
pub func content_security_policy_directives_keyword_sources_initialize_strings():
    if content_security_policy_directives_keyword_sources_strings_initialized:
        return
    content_security_policy_directives_keyword_sources_self = ak.fly_string_from_str("'self'")
    content_security_policy_directives_keyword_sources_unsafe_inline = ak.fly_string_from_str("'unsafe-inline'")
    content_security_policy_directives_keyword_sources_unsafe_eval = ak.fly_string_from_str("'unsafe-eval'")
    content_security_policy_directives_keyword_sources_strict_dynamic = ak.fly_string_from_str("'strict-dynamic'")
    content_security_policy_directives_keyword_sources_unsafe_hashes = ak.fly_string_from_str("'unsafe-hashes'")
    content_security_policy_directives_keyword_sources_report_sample = ak.fly_string_from_str("'report-sample'")
    content_security_policy_directives_keyword_sources_unsafe_allow_redirects = ak.fly_string_from_str("'unsafe-allow-redirects'")
    content_security_policy_directives_keyword_sources_wasm_unsafe_eval = ak.fly_string_from_str("'wasm-unsafe-eval'")
    content_security_policy_directives_keyword_sources_strings_initialized = true