[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/bash-completion 6bf1536325 150/313: Fix occasional escapin
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/bash-completion 6bf1536325 150/313: Fix occasional escaping issue with candidates containing quotes. |
Date: |
Sat, 3 Dec 2022 10:59:25 -0500 (EST) |
branch: elpa/bash-completion
commit 6bf153632565c863cff2f7ed2688aec988d5c5b0
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>
Fix occasional escaping issue with candidates containing quotes.
bash-completion-escape-candidate used to attempt detect quoted
strings. The idea was that programmable completion could return quoted
strings. It's impossible, though, functions fill in results as bash
strings in COMPRELPY; they don't print them.
The commit f3b11e1 broke that idea by calling
bash-completion-escape-candidate only on the substring that follows
the stub to be completed. Since that change, single or double quotes
anywhere in the strings could end up not being escaped when they
should have been, just because they happened to be the first part of
the string to append to the completion candidate.
Example:
cat Documents/Modes\ d<point>
Now completes to:
cat Documents/Modes\ d\'emplois<point>
But would, before this commit, complete to:
cat Documents/Modes\ d'emplois<point>
---
bash-completion-test.el | 17 ++++++++++-------
bash-completion.el | 3 +--
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/bash-completion-test.el b/bash-completion-test.el
index 1fcd7cba49..cde751e50b 100644
--- a/bash-completion-test.el
+++ b/bash-completion-test.el
@@ -594,13 +594,16 @@ garbage
(should (equal "hel\\lo, \\you"
(bash-completion-escape-candidate "hel\\lo, \\you" ?\")))
- ;; no quote not if double quoted
- (should (equal "\"hello, you"
- (bash-completion-escape-candidate "\"hello, you" nil)))
-
- ;; no quote not if single quoted
- (should (equal "'hello, you"
- (bash-completion-escape-candidate "'hello, you" nil))))
+ ;; starts with quotes or special char
+ (should (equal "\\\"\\\"hello" (bash-completion-escape-candidate "\"\"hello"
nil)))
+ (should (equal "\\'\\'hello" (bash-completion-escape-candidate "''hello"
nil)))
+ (should (equal "\\#\\#hello" (bash-completion-escape-candidate "##hello"
nil)))
+ (should (equal "\\\"\\\"hello" (bash-completion-escape-candidate "\"\"hello"
?\")))
+ (should (equal "''hello" (bash-completion-escape-candidate "''hello" ?\")))
+ (should (equal "##hello" (bash-completion-escape-candidate "##hello" ?\")))
+ (should (equal "\"\"hello" (bash-completion-escape-candidate "\"\"hello"
?')))
+ (should (equal "'\\'''\\''hello" (bash-completion-escape-candidate "''hello"
?')))
+ (should (equal "##hello" (bash-completion-escape-candidate "##hello" ?'))))
(ert-deftest bash-completion-quote-test ()
;; allowed
diff --git a/bash-completion.el b/bash-completion.el
index 89d953e631..ca15281907 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -856,8 +856,7 @@ OPEN-QUOTE, either nil, ' or \".
Return a possibly escaped version of COMPLETION-CANDIDATE."
(cond
((zerop (length completion-candidate)) "")
- ((and (null open-quote)
- (null (string-match "^['\"]" completion-candidate)))
+ ((null open-quote)
(replace-regexp-in-string
"\n" "'\n'"
(replace-regexp-in-string
- [nongnu] elpa/bash-completion 7a1f127851 292/313: Test and fix the dynamic table function that's returned., (continued)
- [nongnu] elpa/bash-completion 7a1f127851 292/313: Test and fix the dynamic table function that's returned., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3dbbd1beff 293/313: Fix tests to run under Emacs 24.3., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d47edb9d41 294/313: Bump version to 3.1, a bugfix release., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion faefaf6950 298/313: Add command M-x bash-completion-debug, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fa5557709e 300/313: GitHub Actions now runs tests on Emacs 27.1., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion fd853663ee 304/313: Detect non-responsive processes more quickly., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 65e54c6f9c 307/313: Temporarily revert fixes for issue #44., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion d9c97b741d 309/313: Attempt to fix automated tests., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 29b5fc860a 312/313: Shorten overly long docstring (#53), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 3ffc296e0b 149/313: Close opened quote for all completion candidate that don't end with a, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 6bf1536325 150/313: Fix occasional escaping issue with candidates containing quotes.,
ELPA Syncer <=
- [nongnu] elpa/bash-completion 7ce100b7eb 006/313: cursor position, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 21149fdc27 152/313: Introduce the variable bash-completion-start-files, that allow, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 31bc1c1c21 161/313: Compile bash-completion.el before running tests., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 054ecdfce3 290/313: ignore file ert-profile created by ert-runner, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c444230670 154/313: Add run_tests.sh, to run tests from the command-line, with specific, ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion 0709a9803d 303/313: Support newlines in the output of complete -p., ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion c5eaeed156 311/313: Always ensure that a copy of the candidate list is returned (#48), ELPA Syncer, 2022/12/03
- [nongnu] elpa/bash-completion f6e1c44057 013/313: put everything together, ELPA Syncer, 2022/12/03