diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c index 06b813c031..d1af11318a 100644 --- a/src/basic/extract-word.c +++ b/src/basic/extract-word.c @@ -69,14 +69,14 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra return -ENOMEM; if (c == 0) { - if ((flags & EXTRACT_CUNESCAPE_RELAX) && + if ((flags & EXTRACT_UNESCAPE_RELAX) && (quote == 0 || flags & EXTRACT_RELAX)) { /* If we find an unquoted trailing backslash and we're in - * EXTRACT_CUNESCAPE_RELAX mode, keep it verbatim in the + * EXTRACT_UNESCAPE_RELAX mode, keep it verbatim in the * output. * * Unbalanced quotes will only be allowed in EXTRACT_RELAX - * mode, EXTRACT_CUNESCAPE_RELAX mode does not allow them. + * mode, EXTRACT_UNESCAPE_RELAX mode does not allow them. */ s[sz++] = '\\'; goto finish_force_terminate; @@ -105,7 +105,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra (strchr(separators, **p) || **p == '\\')) /* An escaped separator char or the escape char itself */ s[sz++] = c; - else if (flags & EXTRACT_CUNESCAPE_RELAX) { + else if (flags & EXTRACT_UNESCAPE_RELAX) { s[sz++] = '\\'; s[sz++] = c; } else @@ -196,7 +196,7 @@ int extract_first_word_and_warn( const char *rvalue) { /* Try to unquote it, if it fails, warn about it and try again - * but this time using EXTRACT_CUNESCAPE_RELAX to keep the + * but this time using EXTRACT_UNESCAPE_RELAX to keep the * backslashes verbatim in invalid escape sequences. */ const char *save; @@ -207,11 +207,11 @@ int extract_first_word_and_warn( if (r >= 0) return r; - if (r == -EINVAL && !(flags & EXTRACT_CUNESCAPE_RELAX)) { + if (r == -EINVAL && !(flags & EXTRACT_UNESCAPE_RELAX)) { - /* Retry it with EXTRACT_CUNESCAPE_RELAX. */ + /* Retry it with EXTRACT_UNESCAPE_RELAX. */ *p = save; - r = extract_first_word(p, ret, separators, flags|EXTRACT_CUNESCAPE_RELAX); + r = extract_first_word(p, ret, separators, flags|EXTRACT_UNESCAPE_RELAX); if (r >= 0) { /* It worked this time, hence it must have been an invalid escape sequence. */ log_syntax(unit, LOG_WARNING, filename, line, EINVAL, "Ignoring unknown escape sequences: \"%s\"", *ret); diff --git a/src/basic/extract-word.h b/src/basic/extract-word.h index 3c1e7d98b6..0e9e77e93d 100644 --- a/src/basic/extract-word.h +++ b/src/basic/extract-word.h @@ -6,7 +6,7 @@ typedef enum ExtractFlags { EXTRACT_RELAX = 1 << 0, /* Allow unbalanced quote and eat up trailing backslash. */ EXTRACT_CUNESCAPE = 1 << 1, /* Unescape known escape sequences. */ - EXTRACT_CUNESCAPE_RELAX = 1 << 2, /* Allow and keep unknown escape sequences, allow and keep trailing backslash. */ + EXTRACT_UNESCAPE_RELAX = 1 << 2, /* Allow and keep unknown escape sequences, allow and keep trailing backslash. */ EXTRACT_UNESCAPE_SEPARATORS = 1 << 3, /* Unescape separators (those specified, or whitespace by default). */ EXTRACT_UNQUOTE = 1 << 4, /* Remove quoting with "" and ''. */ EXTRACT_DONT_COALESCE_SEPARATORS = 1 << 5, /* Don't treat multiple adjacent separators as one */ diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index f2a3316251..87d1794a74 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -348,7 +348,7 @@ int config_parse_dnssd_txt( int r; r = extract_first_word(&rvalue, &word, NULL, - EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX); + EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_RELAX); if (r == 0) break; if (r == -ENOMEM) diff --git a/src/test/test-extract-word.c b/src/test/test-extract-word.c index 217c600dac..f1085266df 100644 --- a/src/test/test-extract-word.c +++ b/src/test/test-extract-word.c @@ -172,19 +172,19 @@ static void test_extract_first_word(void) { assert_se(isempty(p)); p = original = "fooo\\"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNESCAPE_RELAX) > 0); assert_se(streq(t, "fooo\\")); free(t); assert_se(isempty(p)); p = original = "fooo\\"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE_RELAX|EXTRACT_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNESCAPE_RELAX|EXTRACT_RELAX) > 0); assert_se(streq(t, "fooo\\")); free(t); assert_se(isempty(p)); p = original = "fooo\\"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_RELAX) > 0); assert_se(streq(t, "fooo\\")); free(t); assert_se(isempty(p)); @@ -230,17 +230,17 @@ static void test_extract_first_word(void) { assert_se(isempty(p)); p = original = "\"foo\\"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE_RELAX) == -EINVAL); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_UNESCAPE_RELAX) == -EINVAL); assert_se(p == original + 5); p = original = "\"foo\\"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE_RELAX|EXTRACT_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_UNESCAPE_RELAX|EXTRACT_RELAX) > 0); assert_se(streq(t, "foo\\")); free(t); assert_se(isempty(p)); p = original = "\"foo\\"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX|EXTRACT_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_RELAX|EXTRACT_RELAX) > 0); assert_se(streq(t, "foo\\")); free(t); assert_se(isempty(p)); @@ -252,13 +252,13 @@ static void test_extract_first_word(void) { assert_se(p == original + 10); p = original = "fooo\\ bar quux"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNESCAPE_RELAX) > 0); assert_se(streq(t, "fooo bar")); free(t); assert_se(p == original + 10); p = original = "fooo\\ bar quux"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE_RELAX|EXTRACT_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_UNESCAPE_RELAX|EXTRACT_RELAX) > 0); assert_se(streq(t, "fooo bar")); free(t); assert_se(p == original + 10); @@ -268,7 +268,7 @@ static void test_extract_first_word(void) { assert_se(p == original + 5); p = original = "fooo\\ bar quux"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_RELAX) > 0); assert_se(streq(t, "fooo\\ bar")); free(t); assert_se(p == original + 10); @@ -278,13 +278,13 @@ static void test_extract_first_word(void) { assert_se(p == original + 1); p = original = "\\w+@\\K[\\d.]+"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_RELAX) > 0); assert_se(streq(t, "\\w+@\\K[\\d.]+")); free(t); assert_se(isempty(p)); p = original = "\\w+\\b"; - assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE|EXTRACT_CUNESCAPE_RELAX) > 0); + assert_se(extract_first_word(&p, &t, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_RELAX) > 0); assert_se(streq(t, "\\w+\b")); free(t); assert_se(isempty(p)); diff --git a/src/test/test-strv.c b/src/test/test-strv.c index 162d8bed95..039bb2c78a 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -333,12 +333,12 @@ static void test_strv_split(void) { l = strv_free_erase(l); assert_se(strv_split_full(&l, " 'one' \" two\t three \"' four five", NULL, - EXTRACT_UNQUOTE | EXTRACT_RELAX | EXTRACT_CUNESCAPE_RELAX) == 2); + EXTRACT_UNQUOTE | EXTRACT_RELAX | EXTRACT_UNESCAPE_RELAX) == 2); assert_se(strv_equal(l, (char**) input_table_quoted_joined)); l = strv_free_erase(l); - assert_se(strv_split_full(&l, "\\", NULL, EXTRACT_UNQUOTE | EXTRACT_RELAX | EXTRACT_CUNESCAPE_RELAX) == 1); + assert_se(strv_split_full(&l, "\\", NULL, EXTRACT_UNQUOTE | EXTRACT_RELAX | EXTRACT_UNESCAPE_RELAX) == 1); assert_se(strv_equal(l, STRV_MAKE("\\"))); }