mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 13:20:59 +00:00 
			
		
		
		
	 e34a6c86b9
			
		
	
	
		e34a6c86b9
		
	
	
	
	
		
			
			These form the basis of Content Security Policy. A policy is a collection of directives that are parsed from either the Content-Security-Policy(-Report-Only) HTTP header, or the `<meta>` element. The directives are what restrict the operations can be performed in the current global execution context. For example, "frame-ancestors: none" tells us to prevent the page from being loaded in an embedded context, such as `<iframe>`. You can see it a bit like OpenBSD's pledge() functionality, but for the web platform: https://man.openbsd.org/pledge.2
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			808 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			808 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <LibJS/Runtime/Realm.h>
 | |
| #include <LibWeb/ContentSecurityPolicy/Directives/Directive.h>
 | |
| #include <LibWeb/ContentSecurityPolicy/Directives/DirectiveFactory.h>
 | |
| #include <LibWeb/ContentSecurityPolicy/Directives/SerializedDirective.h>
 | |
| 
 | |
| namespace Web::ContentSecurityPolicy::Directives {
 | |
| 
 | |
| GC_DEFINE_ALLOCATOR(Directive);
 | |
| 
 | |
| Directive::Directive(String name, Vector<String> value)
 | |
|     : m_name(move(name))
 | |
|     , m_value(move(value))
 | |
| {
 | |
| }
 | |
| 
 | |
| GC::Ref<Directive> Directive::clone(JS::Realm& realm) const
 | |
| {
 | |
|     return create_directive(realm, m_name, m_value);
 | |
| }
 | |
| 
 | |
| SerializedDirective Directive::serialize() const
 | |
| {
 | |
|     return SerializedDirective {
 | |
|         .name = m_name,
 | |
|         .value = m_value,
 | |
|     };
 | |
| }
 | |
| 
 | |
| }
 |