LibRegex+LibUnicode: Add unicode string properties

This commit is contained in:
aplefull 2025-07-24 00:16:08 +02:00 committed by Tim Flynn
parent 8c8961171c
commit 7ce4abe330
Notes: github-actions[bot] 2025-10-24 17:26:08 +00:00
6 changed files with 139 additions and 40 deletions

View file

@ -2463,6 +2463,19 @@ bool ECMA262Parser::parse_nested_class(Vector<regex::CompareTypeAndValuePair>& c
compares.empend(CompareTypeAndValuePair { CharacterCompareType::Inverse, 0 });
property.visit(
[&](Unicode::Property property) {
if (Unicode::is_ecma262_string_property(property)) {
if (negated) {
set_error(Error::InvalidNameForProperty);
return;
}
for (auto const& compare : compares) {
if (compare.type == CharacterCompareType::Inverse) {
set_error(Error::NegatedCharacterClassStrings);
return;
}
}
}
compares.empend(CompareTypeAndValuePair { CharacterCompareType::Property, (ByteCodeValueType)property.value() });
},
[&](Unicode::GeneralCategory general_category) {
@ -2506,8 +2519,13 @@ bool ECMA262Parser::parse_unicode_property_escape(PropertyEscape& property, bool
property = move(*parsed_property);
return property.visit(
[this](Unicode::Property property) {
if (!Unicode::is_ecma262_property(property)) {
[this, negated](Unicode::Property property) {
if (Unicode::is_ecma262_string_property(property)) {
if (!m_parser_state.regex_options.has_flag_set(AllFlags::UnicodeSets) || negated) {
set_error(Error::InvalidNameForProperty);
return false;
}
} else if (!Unicode::is_ecma262_property(property)) {
set_error(Error::InvalidNameForProperty);
return false;
}