From 7e9d65e4c6e8d12292534a545228241e205d8288 Mon Sep 17 00:00:00 2001 From: Richard Quadling Date: Fri, 19 Nov 2021 19:44:24 +0000 Subject: [PATCH] Attempt to fix the lack of escaping of double quotes for zsh completion --- src/DumpCommand.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/DumpCommand.php b/src/DumpCommand.php index d15ca46..9ef33e1 100644 --- a/src/DumpCommand.php +++ b/src/DumpCommand.php @@ -153,10 +153,17 @@ private function render($template, $vars) $helpers = array( 'zsh_describe' => function($value, $description = null) { $value = '"'.str_replace(':', '\\:', $value); + + // Temporarily replace " with something replaceable after escapeshellcmd + $description = str_replace('"', '__DOUBLE_QUOTE__', $description); + if (!empty($description)) { $value .= ':'.escapeshellcmd($description); } + // Restore and escape " + $value = str_replace('__DOUBLE_QUOTE__', '\"', $value); + return $value.'"'; } );