Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bad replace in parser.py. #694

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading