mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 00:32:45 +00:00 
			
		
		
		
	LibWebView: Do not treat prefix of public suffix as valid public suffix
This commit is contained in:
		
							parent
							
								
									dbae1873ec
								
							
						
					
					
						commit
						8dfca6c464
					
				
					 1 changed files with 5 additions and 7 deletions
				
			
		|  | @ -44,9 +44,9 @@ ErrorOr<void> generate_header_file(Core::InputBufferedFile&, Core::File& file) | ||||||
|     generator.append(R"~~~( |     generator.append(R"~~~( | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <AK/DeprecatedString.h> |  | ||||||
| #include <AK/Forward.h> | #include <AK/Forward.h> | ||||||
| #include <AK/Trie.h> | #include <AK/Trie.h> | ||||||
|  | #include <AK/Variant.h> | ||||||
| 
 | 
 | ||||||
| namespace WebView { | namespace WebView { | ||||||
| 
 | 
 | ||||||
|  | @ -70,7 +70,7 @@ public: | ||||||
|     ErrorOr<Optional<String>> get_public_suffix(StringView string); |     ErrorOr<Optional<String>> get_public_suffix(StringView string); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     Trie<char, DeprecatedString> m_dictionary; |     Trie<char, Empty> m_dictionary; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  | @ -118,13 +118,11 @@ static constexpr auto s_public_suffixes = Array {)~~~"); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| PublicSuffixData::PublicSuffixData() | PublicSuffixData::PublicSuffixData() | ||||||
|     : m_dictionary('/', "") |     : m_dictionary('/') | ||||||
| { | { | ||||||
|     // FIXME: Reduce the depth of this trie
 |     // FIXME: Reduce the depth of this trie
 | ||||||
|     for (auto str : s_public_suffixes) { |     for (auto str : s_public_suffixes) { | ||||||
|         MUST(m_dictionary.insert(str.begin(), str.end(), str, [](auto& parent, auto& it) -> Optional<DeprecatedString> { |         MUST(m_dictionary.insert(str.begin(), str.end(), Empty {}, [](auto const&, auto const&) -> Optional<Empty> { return {}; })); | ||||||
|             return DeprecatedString::formatted("{}{}", parent.metadata_value(), *it); |  | ||||||
|         })); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -132,7 +130,7 @@ bool PublicSuffixData::is_public_suffix(StringView host) | ||||||
| { | { | ||||||
|     auto it = host.begin(); |     auto it = host.begin(); | ||||||
|     auto& node = m_dictionary.traverse_until_last_accessible_node(it, host.end()); |     auto& node = m_dictionary.traverse_until_last_accessible_node(it, host.end()); | ||||||
|     return it.is_end() && node.metadata().has_value(); |     return it.is_end() && node.has_metadata(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ErrorOr<Optional<String>> PublicSuffixData::get_public_suffix(StringView string) | ErrorOr<Optional<String>> PublicSuffixData::get_public_suffix(StringView string) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Klishch
						Dan Klishch