Skip to content
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
12 changes: 12 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,15 @@ def test_parse_multiline_string_ignore_the_first_newline() -> None:
content = 'a = """\r\nfoo\n"""'
parser = Parser(content)
assert parser.parse() == {"a": "foo\n"}


def test_parse_multiline_basic_string_with_crlf() -> None:
content = 'a = """foo\r\nbar"""'
parser = Parser(content)
assert parser.parse() == {"a": "foo\r\nbar"}


def test_parse_multiline_literal_string_with_crlf() -> None:
content = "a = '''foo\r\nbar'''"
parser = Parser(content)
assert parser.parse() == {"a": "foo\r\nbar"}
2 changes: 2 additions & 0 deletions tomlkit/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ def _parse_string(self, delim: StringType) -> String:
with self._state(restore=True):
if not self.inc() or self._current != "\n":
raise self.parse_error(InvalidControlChar, CTRL_M, "strings")
value += self._current
self.inc(exception=UnexpectedEofError)
elif not escaped and self._current == delim.unit:
# try to process current as a closing delim
original = self.extract()
Expand Down
Loading