Skip to content

Commit

Permalink
Merge pull request #694 from mtr-d3v/fix_issue_525
Browse files Browse the repository at this point in the history
Fixed a bad replace in parser.py.
  • Loading branch information
niccokunzmann committed Jul 17, 2024
2 parents 3f20966 + 054066a commit bde1275
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ New features:
Bug fixes:

- Fix link to stable release of tox in documentation.
- Fix a bad bytes replace in unescape_char.

6.0.0a0 (2024-07-03)
--------------------
Expand Down
2 changes: 1 addition & 1 deletion src/icalendar/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def unescape_char(text):
elif isinstance(text, bytes):
return text.replace(b'\\N', b'\\n')\
.replace(b'\r\n', b'\n')\
.replace(b'\n', b'\n')\
.replace(b'\\n', b'\n')\
.replace(b'\\,', b',')\
.replace(b'\\;', b';')\
.replace(b'\\\\', b'\\')
Expand Down
6 changes: 5 additions & 1 deletion src/icalendar/tests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import base64
from icalendar import Calendar, vRecur, vBinary, Event
from datetime import datetime
from icalendar.parser import Contentline, Parameters
from icalendar.parser import Contentline, Parameters, unescape_char

@pytest.mark.parametrize('calendar_name', [
# Issue #178 - A component with an unknown/invalid name is represented
Expand Down Expand Up @@ -188,3 +188,7 @@ def test_escaped_characters_read(event_name, expected_cn, expected_ics, events):
event = events[event_name]
assert event['ORGANIZER'].params['CN'] == expected_cn
assert event['ORGANIZER'].to_ical() == expected_ics.encode('utf-8')

def test_unescape_char():
assert unescape_char(b'123') == b'123'
assert unescape_char(b"\\n") == b"\n"

0 comments on commit bde1275

Please sign in to comment.