mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 13:18:19 +00:00
LibWeb/CSP: Implement the webrtc directive
This commit is contained in:
parent
855e17529c
commit
a5e2fd2e12
Notes:
github-actions[bot]
2025-08-07 17:26:43 +00:00
Author: https://github.com/Lubrsi
Commit: a5e2fd2e12
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5765
5 changed files with 64 additions and 0 deletions
|
@ -70,6 +70,7 @@ set(SOURCES
|
|||
ContentSecurityPolicy/Directives/StyleSourceAttributeDirective.cpp
|
||||
ContentSecurityPolicy/Directives/StyleSourceDirective.cpp
|
||||
ContentSecurityPolicy/Directives/StyleSourceElementDirective.cpp
|
||||
ContentSecurityPolicy/Directives/WebRTCDirective.cpp
|
||||
ContentSecurityPolicy/Directives/WorkerSourceDirective.cpp
|
||||
ContentSecurityPolicy/Policy.cpp
|
||||
ContentSecurityPolicy/PolicyList.cpp
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <LibWeb/ContentSecurityPolicy/Directives/StyleSourceAttributeDirective.h>
|
||||
#include <LibWeb/ContentSecurityPolicy/Directives/StyleSourceDirective.h>
|
||||
#include <LibWeb/ContentSecurityPolicy/Directives/StyleSourceElementDirective.h>
|
||||
#include <LibWeb/ContentSecurityPolicy/Directives/WebRTCDirective.h>
|
||||
#include <LibWeb/ContentSecurityPolicy/Directives/WorkerSourceDirective.h>
|
||||
|
||||
namespace Web::ContentSecurityPolicy::Directives {
|
||||
|
@ -94,6 +95,9 @@ GC::Ref<Directive> create_directive(GC::Heap& heap, String name, Vector<String>
|
|||
if (name == Names::StyleSrcElem)
|
||||
return heap.allocate<StyleSourceElementDirective>(move(name), move(value));
|
||||
|
||||
if (name == Names::WebRTC)
|
||||
return heap.allocate<WebRTCDirective>(move(name), move(value));
|
||||
|
||||
if (name == Names::WorkerSrc)
|
||||
return heap.allocate<WorkerSourceDirective>(move(name), move(value));
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 directive’s 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Luke Wilde <luke@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/ContentSecurityPolicy/Directives/Directive.h>
|
||||
|
||||
namespace Web::ContentSecurityPolicy::Directives {
|
||||
|
||||
// https://w3c.github.io/webappsec-csp/#directive-webrtc
|
||||
class WebRTCDirective final : public Directive {
|
||||
GC_CELL(WebRTCDirective, Directive)
|
||||
GC_DECLARE_ALLOCATOR(WebRTCDirective);
|
||||
|
||||
public:
|
||||
virtual ~WebRTCDirective() = default;
|
||||
|
||||
[[nodiscard]] virtual Result webrtc_pre_connect_check(GC::Ref<Policy const>) const override;
|
||||
|
||||
private:
|
||||
WebRTCDirective(String name, Vector<String> value);
|
||||
};
|
||||
|
||||
}
|
|
@ -157,6 +157,7 @@ class ScriptSourceElementDirective;
|
|||
class StyleSourceAttributeDirective;
|
||||
class StyleSourceDirective;
|
||||
class StyleSourceElementDirective;
|
||||
class WebRTCDirective;
|
||||
class WorkerSourceDirective;
|
||||
struct SerializedDirective;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue