From cf96c562e10ac3c13ab39dd527cf7337791f6473 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 14 Dec 2017 22:41:14 -0600 Subject: [PATCH] libpkgconf: argvsplit: fix escape handling in tokenizer (closes #163) --- libpkgconf/argvsplit.c | 7 +------ libpkgconf/fragment.c | 2 +- tests/parser.sh | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/libpkgconf/argvsplit.c b/libpkgconf/argvsplit.c index 4553154..02ce1a3 100644 --- a/libpkgconf/argvsplit.c +++ b/libpkgconf/argvsplit.c @@ -88,12 +88,7 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv) *dst_iter++ = *src_iter; } else - { - if (*src_iter == '\\') - *dst_iter++ = '\\'; - *dst_iter++ = *src_iter; - } escaped = false; } @@ -101,7 +96,7 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv) { if (*src_iter == quote) quote = 0; - else if (*src_iter == '\\') + else if (*src_iter == '\\' && quote != '\'') escaped = true; else *dst_iter++ = *src_iter; diff --git a/libpkgconf/fragment.c b/libpkgconf/fragment.c index 7b66756..1ea91ee 100644 --- a/libpkgconf/fragment.c +++ b/libpkgconf/fragment.c @@ -405,7 +405,7 @@ fragment_should_quote(const pkgconf_fragment_t *frag) (*src > 'Z' && *src < '^') || (*src == '`') || (*src > 'z' && *src < '~') || - (*src > '~')) && *src != '\\') + (*src > '~'))) return true; } diff --git a/tests/parser.sh b/tests/parser.sh index 5415641..0048633 100755 --- a/tests/parser.sh +++ b/tests/parser.sh @@ -118,7 +118,7 @@ escaped_backslash_body() { atf_check \ -e ignore \ - -o inline:"-IC:\\\\\\\\A \n" \ + -o inline:"'-IC:\\A' \n" \ pkgconf --with-path=${selfdir}/lib1 --cflags escaped-backslash }