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

Parser fails on datetime followed by space #260

Closed
ghost opened this issue Jan 24, 2023 · 0 comments · Fixed by #268
Closed

Parser fails on datetime followed by space #260

ghost opened this issue Jan 24, 2023 · 0 comments · Fixed by #268

Comments

@ghost
Copy link

ghost commented Jan 24, 2023

The tomlkit parser rejects datetime values in certain cases.
All of the following examples trigger an error:

import tomlkit
tomlkit.parse("d = 2013-01-24 13:48:01.123456 ")
tomlkit.parse("d = 2013-01-24 13:48:01.123456 \n")
tomlkit.parse("d = 2013-01-24 13:48:01 \n")
tomlkit.parse("d = 2013-01-24 13:48:01Z \n")
tomlkit.parse("d = [2013-01-24 13:48:01 ]\n")
tomlkit.parse("d = [2013-01-24 13:48:01 , 2013-01-25 13:56:01]\n")
tomlkit.parse("d = { a = 2013-01-24 13:48:01 }\n")

with the parser typically raising:

tomlkit.exceptions.InvalidDateError: Invalid date at line 1 col 31

It looks like this issue is triggered only if there is a space (instead of "T") between the date and the time, and another space appears immediately after the time.

This issue applies to the latest commit 6512eaa on master as well as the latest release v0.11.6.

I'm experimenting with a TOML fuzzer which revealed this issue. I guess most normal applications are not likely to hit this case, so I understand if this gets low priority. It still seems worthwhile to fix it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

0 participants