extract-word: also handle EXTRACT_UNESCAPE_RELAX in the escape branch
extract_first_word() handled a backslash followed by another character in the escape-processing branch only when EXTRACT_CUNESCAPE or EXTRACT_UNESCAPE_SEPARATORS was set. With EXTRACT_UNESCAPE_RELAX alone, the backslash was silently dropped and only the following character kept, which is inconsistent with the documented "keep invalid escapes verbatim" intent of RELAX. Let RELAX also enter that branch, so an invalid escape like "\x" is preserved verbatim as "\x" rather than collapsing to "x". EXTRACT_UNESCAPE_RELAX is not used on its own anywhere outside the test cases — the non-test callers always combine it with EXTRACT_CUNESCAPE, which already enters this branch — so only the test cases that use RELAX by itself are affected, and their expectations are updated accordingly.
This commit is contained in:
@@ -78,7 +78,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (flags & (EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS)) {
|
||||
if (flags & (EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS|EXTRACT_UNESCAPE_RELAX)) {
|
||||
bool eight_bit = false;
|
||||
char32_t u;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user