Skip to content

Commit

Permalink
Rollbacked support for empty strings in powershell as it doesn't pass on
Browse files Browse the repository at this point in the history
the CI.
  • Loading branch information
nicolas-van committed Apr 25, 2023
1 parent 186cf7a commit 60fabe1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Also, while this library is in Python, it aims to be a reference implementation

## Known limitations

* ASCII control codes are not supported. This notably includes `\t`, `\r` and `\n`. (There doest't seem to have proper ways to encode these characters in CMD nor Powershell anyway.)
* Some common control characters like `\t` and `\n` are supported in Powershell. Other control characters are not.
* No control characters are supported at all in CMD, including `\t` and `\n`. (There doest't seem to have proper ways to encode these characters in CMD.)
* Empty strings are not supported in Powershell. (It doesn't seem to be possible at all to pass an empty string in all versions of Powershell.)

## About non-ASCII characters

Expand Down
9 changes: 6 additions & 3 deletions test_win_cmd_escaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ def test_basic_calls(self):
self._test_str("hello")
self._test_str("hello world")

def test_empty(self):
self._test_str("")

def test_printable_ascii_only_char(self):
for i in range(32, 127):
character = chr(i)
Expand Down Expand Up @@ -129,6 +126,9 @@ def test_backticks(self):

class AllCmdTests(AllTests):

def test_empty(self):
self._test_str("")

def test_other_control_characters(self):
for c in powershell_supported_control_characters:
self._test_unsupported(c)
Expand Down Expand Up @@ -158,6 +158,9 @@ def escape(self, str):
def run_echoer(self, str):
return test_utils.run_echoer_with_powershell_through_script(str)

def test_empty(self):
self._test_unsupported("")

def test_other_control_characters(self):
for c in powershell_supported_control_characters:
self._test_str(c)
Expand Down
2 changes: 2 additions & 0 deletions win_cmd_escaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def escape_powershell_argument_script(str):
"""
Escapes an argument for Powershell.
"""
if str == "":
raise ValueError("Empty strings are not supported")

acc = ""
for i in range(len(str)):
Expand Down

0 comments on commit 60fabe1

Please sign in to comment.