mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +00:00
LibWeb: Add name validation and document check to setAttribute
Co-authored-by: Rayyan Hamid <rayyanbwp@gmail.com> Co-authored-by: Christian Ewing <u1273549@utah.edu> Co-authored-by: Austin Fashimpaur <austin.fashimpaur@gmail.com>
This commit is contained in:
parent
5ed7cd6e32
commit
13abb1b2c7
Notes:
sideshowbarker
2024-07-17 07:16:27 +09:00
Author: https://github.com/alextrnnn 🔰
Commit: 13abb1b2c7
Pull-request: https://github.com/SerenityOS/serenity/pull/24000
Reviewed-by: https://github.com/trflynn89 ✅
6 changed files with 45 additions and 8 deletions
|
@ -2628,12 +2628,13 @@ static inline bool is_valid_name_character(u32 code_point)
|
|||
|| (code_point >= 0x203f && code_point <= 0x2040);
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/xml/#NT-Name
|
||||
bool Document::is_valid_name(String const& name)
|
||||
{
|
||||
auto code_points = Utf8View { name };
|
||||
auto it = code_points.begin();
|
||||
if (code_points.is_empty())
|
||||
if (name.is_empty())
|
||||
return false;
|
||||
auto code_points = name.code_points();
|
||||
auto it = code_points.begin();
|
||||
|
||||
if (!is_valid_name_start_character(*it))
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue