Skip to content

Commit

Permalink
StringProcessing: Fix single-backslash bug
Browse files Browse the repository at this point in the history
Bug fixed in function unescape().

Fixes #483.
  • Loading branch information
Makman2 committed Apr 27, 2015
1 parent 4ff6ebc commit c598136
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion coalib/parsing/StringProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def unescape(string):
:param string: The string to unescape.
"""
regex = r"\\(.)"
regex = r"\\(.)|\\$"

def replacement_function(match):
return match.group(1)
Expand Down
8 changes: 7 additions & 1 deletion coalib/tests/parsing/StringProcessingTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def set_up_unescape(self):
r"out1 'str1''str2''str3' out2",
r"",
r"out1 out2 out3",
self.bs,
r"",
self.bs]

def assertSearchForResultEqual(self,
Expand Down Expand Up @@ -1158,6 +1158,12 @@ def test_unescape(self):
for elem in compare:
self.assertEqual(elem[0], elem[1])

# Test unescape() for some special possible flaws.
def test_unescape_custom(self):
self.assertEqual(unescape("hello\\"), "hello")
self.assertEqual(unescape("te\st\\\\"), "test\\")
self.assertEqual(unescape("\\\\\\"), "\\")

def test_position_is_escaped(self):
test_string = r"\\\\\abcabccba###\\13q4ujsabbc\+'**'ac###.#.####-ba"
result_dict = {
Expand Down

2 comments on commit c598136

@sils
Copy link
Member

@sils sils commented on c598136 Apr 28, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@sils
Copy link
Member

@sils sils commented on c598136 Apr 28, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although commit message is not so good a commit message shall not describe what you fix (because thats just one perspective on a change) but the actual change. You can mention what it fixes in the main description below. I'll modify while pushing.

Please sign in to comment.