HappenLee commented on code in PR #66788:
URL: https://github.com/apache/doris/pull/66788#discussion_r3785572466
##########
be/src/exprs/function/like.cpp:
##########
@@ -36,6 +37,109 @@
#include "exprs/function/simple_function_factory.h"
namespace doris {
+namespace {
+
+bool is_larger_than_fifty(std::string_view str) {
+ int number = 0;
+ auto [_, error] = std::from_chars(str.data(), str.data() + str.size(),
number);
+ return error == std::errc() && number > 50;
+}
+
+std::string mask_escaped_characters_and_character_classes(std::string_view
regexp) {
+ std::string masked_regexp(regexp);
+ bool escaped = false;
+ bool in_character_class = false;
+ bool character_class_can_close = false;
+ for (char& masked_character : masked_regexp) {
+ const char current = masked_character;
+ if (escaped) {
+ masked_character = ' ';
+ escaped = false;
+ if (in_character_class) {
+ character_class_can_close = true;
+ }
+ continue;
+ }
+ if (current == '\\') {
+ masked_character = ' ';
+ escaped = true;
+ continue;
+ }
+ if (in_character_class) {
+ masked_character = ' ';
+ if (current == ']' && character_class_can_close) {
+ in_character_class = false;
+ } else if (current != '^' || character_class_can_close) {
Review Comment:
Fixed in 17e768572e5. The masker now tracks separately whether the optional
leading character-class negation marker is still allowed, so the second `^` in
`[^^]` is treated as class content and the following `]` closes the class.
Added direct detection coverage plus both constant-open and execute-time
strict-mode coverage for `[^^](ab?c?d){1000,5000}`. `FunctionLikeTest.*`
passes: 36/36 tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]