ladybird/Libraries/LibWeb/ContentSecurityPolicy/Directives/WebRTCDirective.cpp
2025-08-07 19:24:39 +02:00

31 lines
903 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (c) 2024, Luke Wilde <luke@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/ContentSecurityPolicy/Directives/WebRTCDirective.h>
#include <LibWeb/Infra/Strings.h>
namespace Web::ContentSecurityPolicy::Directives {
GC_DEFINE_ALLOCATOR(WebRTCDirective);
WebRTCDirective::WebRTCDirective(String name, Vector<String> value)
: Directive(move(name), move(value))
{
}
// https://w3c.github.io/webappsec-csp/#webrtc-pre-connect
Directive::Result WebRTCDirective::webrtc_pre_connect_check(GC::Ref<Policy const>) const
{
// 1. If this directives value contains a single item which is an ASCII case-insensitive match for the string
// "'allow'", return "Allowed".
if (value().size() == 1 && value().first().equals_ignoring_ascii_case("'allow'"sv))
return Result::Allowed;
// 2. Return "Blocked".
return Result::Blocked;
}
}