-
-
Notifications
You must be signed in to change notification settings - Fork 14
Add a basic ECMA-262 check helper #2407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,7 @@ auto to_regex(const std::string_view pattern) -> std::optional<Regex> { | |
| return RegexTypeRange{minimum, maximum}; | ||
| } | ||
|
|
||
| const auto pcre2_pattern{preprocess_regex(std::string{pattern})}; | ||
| const auto pcre2_pattern{preprocess_regex<false>(std::string{pattern})}; | ||
| if (!pcre2_pattern.has_value()) { | ||
| return std::nullopt; | ||
| } | ||
|
|
@@ -115,4 +115,27 @@ auto matches_if_valid(const std::string_view pattern, | |
| return regex.has_value() && matches(regex.value(), value); | ||
| } | ||
|
|
||
| auto is_regex_ecma(const std::string_view pattern) -> bool { | ||
| const auto pcre2_pattern{preprocess_regex<false>(std::string{pattern})}; | ||
| if (!pcre2_pattern.has_value()) { | ||
| return false; | ||
| } | ||
|
|
||
| int pcre2_error_code{0}; | ||
| PCRE2_SIZE pcre2_error_offset{0}; | ||
| pcre2_code *pcre2_regex_raw{pcre2_compile( | ||
| reinterpret_cast<PCRE2_SPTR>(pcre2_pattern.value().c_str()), | ||
| pcre2_pattern.value().size(), | ||
| PCRE2_UTF | PCRE2_UCP | PCRE2_NO_AUTO_CAPTURE | PCRE2_DOTALL | | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. src/core/regex/regex.cc:129 — Severity: medium 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage. |
||
| PCRE2_DOLLAR_ENDONLY | PCRE2_NEVER_BACKSLASH_C | PCRE2_NO_UTF_CHECK, | ||
| &pcre2_error_code, &pcre2_error_offset, nullptr)}; | ||
|
|
||
| if (pcre2_regex_raw == nullptr) { | ||
| return false; | ||
| } | ||
|
|
||
| pcre2_code_free(pcre2_regex_raw); | ||
| return true; | ||
| } | ||
|
|
||
| } // namespace sourcemeta::core | ||
Uh oh!
There was an error while loading. Please reload this page.