File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ pyrobase (0.5.2) precise; urgency=low
2+
3+ * Fix: Keep unicode/str type in shell_escape()
4+
5+ -- pyroscope <pyroscope.project@gmail.com> Mon, 01 Jan 2018 14:03:46 +0100
6+
17pyrobase (0.5.1) precise; urgency=low
28
39 * Removed support for Python 2.6
Original file line number Diff line number Diff line change 2424
2525def shell_escape (text , _safe = re .compile (r"^[-._,+a-zA-Z0-9]+$" )):
2626 """Escape given string according to shell rules."""
27- return text if _safe .match (text ) else "'%s'" % text .replace ("'" , r"'\''" )
27+ if not text or _safe .match (text ):
28+ return text
29+
30+ squote = type (text )("'" )
31+ return squote + text .replace (squote , type (text )(r"'\''" )) + squote
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ def test_shell_escape(self):
3333 ("!bang" , "'!bang'" ),
3434 ("d\" q" , "'d\" q'" ),
3535 ("s'q" , r"'s'\''q'" ),
36+ (b"abc" , b"abc" ),
37+ (b"!bang" , b"'!bang'" ),
38+ (b"\xA0 " , b"'\xA0 '" ),
3639 ]
3740 for val , expected in cases :
3841 result = osutil .shell_escape (val )
You can’t perform that action at this time.
0 commit comments