Skip to content

Commit

Permalink
Fix uiri#368:Fix and add test, Lone quote in string isn't parsed corr…
Browse files Browse the repository at this point in the history
…ectly
  • Loading branch information
arturoeanton committed Jul 13, 2021
1 parent 3f637db commit 36dd244
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./tests",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": true,
"python.testing.nosetestsEnabled": false,
"python.testing.unittestEnabled": false
}
7 changes: 7 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

TEST_DICT = {"a": {"b": 1, "c": 2}}

def test_bug_368():
data = toml.loads(toml.dumps({"a": "\""}))
assert "\"" == data["a"]

def test_bug_368Bis():
data = toml.loads(toml.dumps({"a": ''}))
assert '' == data["a"]

def test_bug_148():
assert 'a = "\\u0064"\n' == toml.dumps({'a': '\\x64'})
Expand Down
4 changes: 1 addition & 3 deletions toml/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,9 +872,7 @@ def load_value(self, v, strictly_valid=True):
v = _load_unicode_escapes(hexbytes[0], hexbytes[1:],
prefix)
v = _unescape(v)
if len(v) > 1 and v[1] == quotechar and (len(v) < 3 or
v[1] == v[2]):
v = v[2:-2]

return (v[1:-1], "str")
elif v[0] == '[':
return (self.load_array(v), "array")
Expand Down

0 comments on commit 36dd244

Please sign in to comment.