From fb8f3f1790bb818760134b74e9359c157e357e22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Wed, 3 Apr 2024 15:46:47 +0100 Subject: [PATCH] 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 --- ChangeLog | 12 ++++++++++++ lib/quotearg.c | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e214c08e27..306e4a610b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2024-04-03 Pádraig Brady + + 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 renameatu: handle ENOSYS from renameatx_np diff --git a/lib/quotearg.c b/lib/quotearg.c index c4133f10d6..68b187926e 100644 --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -1,6 +1,6 @@ /* quotearg.c - quote arguments for output - Copyright (C) 1998-2002, 2004-2023 Free Software Foundation, Inc. + Copyright (C) 1998-2002, 2004-2024 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -259,7 +259,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; @@ -302,7 +301,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, } \ while (0) - process_input: + process_input: ; + bool pending_shell_escape_end = false; switch (quoting_style) { -- 2.39.5