Fix comment removal regex
The trailing comment removal pattern unnecessarily required that a leading space is present in all trailing comments. Also, the pattern didn't match if no line ending was included in the SQL statement. The subject ending should be the third valid terminator in addition to UNIX and Windows style line endings.
This commit is contained in:
@ -555,7 +555,7 @@ static pcre2_code* remove_comments_re = NULL;
|
||||
static const PCRE2_SPTR remove_comments_pattern = (PCRE2_SPTR)
|
||||
"(?:`[^`]*`\\K)|"
|
||||
"(\\/[*](?!(M?!)).*?[*]\\/)|"
|
||||
"([[:space:]](?:#.*|--[[:space:]].*(\\n|\\r\\n)))";
|
||||
"((?:#.*|--[[:space:]].*)(\\n|\\r\\n|$))";
|
||||
|
||||
/**
|
||||
* Remove SQL comments from the end of a string
|
||||
|
Reference in New Issue
Block a user