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

Detect invalid control characters #128

Closed
moorereason opened this issue Jan 4, 2022 · 2 comments
Closed

Detect invalid control characters #128

moorereason opened this issue Jan 4, 2022 · 2 comments
Assignees
Labels
bug Something isn't working implemented in v3 Fixes + features which were implemented in v3 release. TOML spec An issue relating to the library's TOML spec conformance.

Comments

@moorereason
Copy link

Environment

toml++ version and/or commit hash:
v3 f3bd22b

Compiler:
gcc 11.1.0

C++ standard mode:
c++20

Target arch:
linux x86_64

Library configuration overrides:
n/a

Relevant compilation flags:
meson build_tt --buildtype=release -Dbuild_tt_encoder=true -Dbuild_tt_decoder=true -Dgenerate_cmake_config=false

Describe the bug

A TOML document containing only invalid control characters should return an error.

For example, a file with on a single byte of 0x0b (vertical tab) or 0x0c (form feed) is an invalid TOML document.

Steps to reproduce (or a small repro code sample)

On Linux with zsh, create a file with only a vertical tab and consume with tt_decoder:

$ echo -n "\v" > tomlpp.1
$ hexdump -C <tomlpp.1
00000000  0b                                                |.|
00000001
$ tt_decoder <tomlpp.1
{}

Additional information

The same file returns an error with other decoders, such as toml.dart:

$ decoder <tomlpp.1
Unhandled exception:
TOML parse error: key expected OR "[" expected OR "[[" expected OR newline or end of input expected at 1:1
#0      TomlParserException.fromResult (package:toml/src/decoder/exception/parser.dart:25)
#1      TomlParserExceptionExtension.valueOrTomlException (package:toml/src/decoder/exception/parser.dart:84)
#2      TomlDocument.parse (package:toml/src/ast/document.dart:33)
#3      main (file:///x/src/github.com/just95/toml.dart/bin/decoder.dart:66)
<asynchronous suspension>

Found while doing differential fuzzing against go-toml.

@moorereason moorereason added the bug Something isn't working label Jan 4, 2022
@marzer marzer added TOML spec An issue relating to the library's TOML spec conformance. v3 labels Jan 4, 2022
marzer added a commit that referenced this issue Jan 4, 2022
also:
- fixed extended-precision fractional times causing parse error instead of truncating per the spec (closes #127)
- fixed some non-spec vertical whitespace being accepted as line breaks (closes #128)
- added `format_flags::allow_unicode_strings`
@marzer
Copy link
Owner

marzer commented Jan 4, 2022

Fixed in the v3 branch, thanks!

@marzer marzer closed this as completed Jan 4, 2022
@marzer marzer added implemented in v3 Fixes + features which were implemented in v3 release. and removed v3 labels Jan 4, 2022
@moorereason
Copy link
Author

Nice. I've submitted a PR to add this to toml-test: toml-lang/toml-test#106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working implemented in v3 Fixes + features which were implemented in v3 release. TOML spec An issue relating to the library's TOML spec conformance.
Projects
None yet
Development

No branches or pull requests

2 participants