]> Savannah Git Hosting - gnulib.git/commitdiff
quotearg: fix shell-escape quoting with single quotes
authorPádraig Brady <P@draigBrady.com>
Wed, 3 Apr 2024 14:46:47 +0000 (15:46 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 8 Apr 2024 10:42:17 +0000 (12:42 +0200)
With shell-escape quoting, we misquoted strings
where the first and last characters required escaping,
while the string also contained single quotes.

* lib/quotearg.c (quotearg_buffer_restyled): Ensure that
pending_shell_escape_end is reset to the initial state
when reprocessing input due to single quotes.
Reported by Grisha Levit

ChangeLog
lib/quotearg.c

index 0a198b207fa27787c3b45f97f4dfcacf68d1ff95..0388bc0749afe51da0742084e7c44198f58c81f9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-04-03  Pádraig Brady  <P@draigBrady.com>
+
+       quotearg: fix shell-escape quoting with single quotes
+       With shell-escape quoting, we misquoted strings
+       where the first and last characters required escaping,
+       while the string also contained single quotes.
+
+       * lib/quotearg.c (quotearg_buffer_restyled): Ensure that
+       pending_shell_escape_end is reset to the initial state
+       when reprocessing input due to single quotes.
+       Reported by Grisha Levit
+
 2024-04-02  Pádraig Brady  <P@draigBrady.com>
 
        renameatu: handle ENOSYS from renameatx_np
index 847101e6059cb434a79c6680e0bdaeb2ae4472f1..5ca511a4924717900fe24dc73a7fec4af454a04b 100644 (file)
@@ -260,7 +260,6 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
   bool backslash_escapes = false;
   bool unibyte_locale = MB_CUR_MAX == 1;
   bool elide_outer_quotes = (flags & QA_ELIDE_OUTER_QUOTES) != 0;
-  bool pending_shell_escape_end = false;
   bool encountered_single_quote = false;
   bool all_c_and_shell_quote_compat = true;
 
@@ -303,7 +302,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
       } \
     while (0)
 
- process_input:
+ process_input: ;
+  bool pending_shell_escape_end = false;
 
   switch (quoting_style)
     {