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

~Fix failing tests for invalid control characters in comments~ invalid #617

Closed

Conversation

jidicula
Copy link
Contributor

@jidicula jidicula commented Oct 5, 2021

Issue: #613

  • Modifies scanComment() to error out early if an illegal character is found
  • Adds illegal characters to scanComment()

Note that the NUL and US control characters weren't causing tests to fail prior to me making my changes... I took a quick look into why but couldn't crack why those tests weren't failing on my machine (TestTOMLTest_Invalid_Control_CommentNull and TestTOMLTest_Invalid_Control_CommentUs).

pelletier and others added 26 commits June 1, 2021 09:10
When parsing strings, they can be referenced directly from the document
when they don't contain escaped characters. This avoids paying to cost
of allocating (and sometimes growing) the bytes buffer unecessarily.
* Use pointers instead of copying around ast.Node

Node is a 56B struct that is constantly in the hot path. Passing nodes
around by copy had a cost that started to add up. This change replaces
them by pointers. Using unsafe pointer arithmetic and converting
sibling/child indexes to relative offsets, it removes the need to carry
around a pointer to the root of the tree. This saves 8B per Node. This
space will be used to store an extra []byte slice to provide contextual
error handling on all nodes, including the ones whose data is different
than the raw input (for example: strings with escaped characters), while
staying under the size of a cache line.

* Remove conditional

* Add Raw to track range in data for parsed values

* Simplify reference tracking
Co-authored-by: Nabetani <takenori@nabetani.sakura.ne.jp>
* Reduces the public API.
* Reuses optimized parsing functions.
* Removes reliance on Google code under Apache license.
Inline call to hexToRune and uses specialized parsing, as found in encoding/json.

Co-authored-by: Thomas Pelletier <thomas@pelletier.codes>
Co-authored-by: Thomas Pelletier <thomas@pelletier.codes>
Minimum supported version: Go 1.16.
When unmarshaling into a nested struct in a map, the value is not
addressable. In that case, make a copy of it and modify it instead.

Fixes pelletier#575
* parser: don't crash on unterminated table key

Fixes pelletier#579

* parser: fix format of error returned by expect

EOF was missing the format string and %U is not very human friendly.
When an invalid TOML expression ends with a comment before the end of
file, the decode error would take a nil from scanComment, which is not
part of the document.

Fixes pelletier#588
…ier#601)

RFC3399 allows for lowercase 't' and 'z' in date-time values.

Fixes pelletier#600
Tests are hidden behind a "testsuite" build tag for now since many tests
are failing.  Use `go test -tags testsuite` to activate.

Use `go generate` to regenerate toml_testgen_test.go.

Co-authored-by: Thomas Pelletier <thomas@pelletier.codes>
When scanning comments, it makes better sense to halt scanning and
immediately return if an illegal character is encountered while
scanning. This can save on performance in the perverse case of an
extremely long comment that has an early offending character.

Related to: pelletier#613
Oddly enough, the test passes when it shouldn't.

Partially resolves: pelletier#613
Oddly enough, the test passes when it shouldn't.

Partially resolves: pelletier#613
@jidicula jidicula closed this Oct 5, 2021
@jidicula
Copy link
Contributor Author

jidicula commented Oct 5, 2021

Sorry, opened a PR against the wrong branch 😓

@jidicula jidicula changed the title Fix failing tests for invalid control characters in comments ~~Fix failing tests for invalid control characters in comments~~ invalid Oct 5, 2021
@jidicula jidicula changed the title ~~Fix failing tests for invalid control characters in comments~~ invalid ~Fix failing tests for invalid control characters in comments~ invalid Oct 5, 2021
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 this pull request may close these issues.

6 participants