mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibWeb: Iterate codepoints instead of characters in is_valid_name
This commit is contained in:
parent
1d7bad5347
commit
149e442c24
1 changed files with 7 additions and 4 deletions
|
@ -1882,14 +1882,17 @@ static inline bool is_valid_name_character(u32 code_point)
|
||||||
|
|
||||||
bool Document::is_valid_name(DeprecatedString const& name)
|
bool Document::is_valid_name(DeprecatedString const& name)
|
||||||
{
|
{
|
||||||
if (name.is_empty())
|
auto code_points = Utf8View { name };
|
||||||
|
auto it = code_points.begin();
|
||||||
|
if (code_points.is_empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!is_valid_name_start_character(name[0]))
|
if (!is_valid_name_start_character(*it))
|
||||||
return false;
|
return false;
|
||||||
|
++it;
|
||||||
|
|
||||||
for (size_t i = 1; i < name.length(); ++i) {
|
for (; it != code_points.end(); ++it) {
|
||||||
if (!is_valid_name_character(name[i]))
|
if (!is_valid_name_character(*it))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue