Skip to content

Detect invalid control characters #128

@moorereason

Description

@moorereason

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.

Metadata

Metadata

Assignees

Labels

TOML specAn issue relating to the library's TOML spec conformance.bugSomething isn't workingimplemented in v3Fixes + features which were implemented in v3 release.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions