Fixed escape_windows_cmd_string not handling ^ correctly

This commit is contained in:
Morten Enemark Lund 2017-08-01 21:43:46 +02:00
parent 5cb3e8dd55
commit 876740b535
3 changed files with 15 additions and 3 deletions

13
news/win_escape.rst Normal file
View file

@ -0,0 +1,13 @@
**Added:** None
**Changed:** None
**Deprecated:** None
**Removed:** None
**Fixed:**
* Fixed a problem with escaping charet (^) character for cmd.exe in the source-cmd function.
**Security:** None

View file

@ -1070,7 +1070,7 @@ def test_dynamic_cwd_tuple_to_str(inp, exp):
('foo&bar', 'foo^&bar'),
('foo$?-/_"\\', 'foo$?-/_^"\\'),
('^&<>|', '^^^&^<^>^|'),
('this /?', 'this /.')
('()<>','^(^)^<^>'),
])
def test_escape_windows_cmd_string(st, esc):
obs = escape_windows_cmd_string(st)

View file

@ -890,9 +890,8 @@ def escape_windows_cmd_string(s):
The escaping is based on details here and empirical testing:
http://www.robvanderwoude.com/escapechars.php
"""
for c in '()%!^<>&|"':
for c in '^()%!<>&|"':
s = s.replace(c, '^' + c)
s = s.replace('/?', '/.')
return s