Skip to content

Commit

Permalink
Fix parse errors when single quotes are present in a table name (pyth…
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater authored Feb 3, 2020
1 parent d6674e7 commit cb6351e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/examples/table_names_with_string_delimiters.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
['Special "table"']
foo = "bar"

["BJ's Restaurant"]
account = "dining"
1 change: 1 addition & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def json_serial(obj):
"newline_in_strings",
"preserve_quotes_in_string",
"string_slash_whitespace_newline",
"table_names_with_string_delimiters",
],
)
def test_parse_can_parse_valid_toml_files(example, example_name):
Expand Down
7 changes: 6 additions & 1 deletion tomlkit/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,12 @@ def _split_table_name(self, name): # type: (str) -> Generator[Key]
continue
elif c in {"'", '"'}:
if in_name:
if t == KeyType.Literal and c == '"':
if (
t == KeyType.Literal
and c == '"'
or t == KeyType.Basic
and c == "'"
):
current += c
continue

Expand Down

0 comments on commit cb6351e

Please sign in to comment.