[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [patch] utils: qs not escaping pipes
From: |
Florian Zumbiehl |
Subject: |
[Chicken-hackers] [patch] utils: qs not escaping pipes |
Date: |
Sun, 17 Feb 2013 15:22:48 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Hi,
I noticed that qs doesn't escape pipe characters. I suggest the patch
below, which not only makes it so that pipes get escaped, but it also
switches away from the blacklist approach, which invariably doesn't
work ;-)
Regards, Florian
---------------------------------------------------------------------------
diff --git a/utils.scm b/utils.scm
index 58469d7..b41c90b 100644
--- a/utils.scm
+++ b/utils.scm
@@ -63,16 +63,16 @@
((mingw32)
(string-append "\"" str "\""))
(else
- (if (zero? (string-length str))
- "''"
+ (string-append
+ "'"
(string-concatenate
(map (lambda (c)
- (if (or (char-whitespace? c)
- (memq c '(#\# #\" #\' #\` #\ยด #\~ #\& #\% #\$ #\! #\*
#\;
- #\< #\> #\\ #\( #\) #\[ #\] #\{ #\} #\?)))
- (string #\\ c)
- (string c)))
- (string->list str)))))))
+ (case c
+ ((#\') "'\\''")
+ ((#\nul) (error 'qs "NUL character can not be represented
in shell string" str))
+ (else (string c))))
+ (string->list str)))
+ "'"))))
;;; Compile and load file