Thomas Pelletier
627dade0c7
Encode: support comment on array tables ( #776 )
...
Fixes #774
2022-05-10 15:17:36 +02:00
Thomas Pelletier
c5ca2c682b
Fix embedded struct with explicit field name ( #773 )
...
Fixes #772
2022-05-09 18:45:02 +02:00
Thomas Pelletier
8bbb673431
Fuzzing setup and fixes ( #755 )
...
* encode: fix localdate formatting
* encode: fix empty key marshaling
* encode: fix invalid quotation of time.Time
* encode: ensure control chars are escaped
* decode: always use UTC for zero tz
* encode: check for invalid characters in keys
* encode: always construct map for empty array tables
* fuzz: add go 1.18 fuzz test
* encode: handle NaNs
* encode: allow new lines in quoted keys
* encode: never emit table inside array
* encode: don't capitalize inf
2022-04-10 21:37:12 -04:00
Thomas Pelletier
89d7b412d8
decode: allow subtables to be defined later ( #750 )
...
Fixes #739
2022-04-07 21:49:16 -04:00
Cameron Moore
146f70ea8a
Decode: use cleaned byte slice throughout parseFloat ( #735 )
...
Fixes #734
2022-01-06 14:34:27 -05:00
Thomas Pelletier
e83cf535f5
Decoder: rename SetStrict to DisallowUnknownFields ( #731 )
2022-01-02 14:32:34 -05:00
Cameron Moore
128b7a8bfb
Decode: check buffer length before parsing simple key ( #717 )
...
Fixes #714
2021-12-29 08:58:42 -05:00
Cameron Moore
892df5c28e
Decode: fix index out of range bug ( #716 )
...
Fixes #715
2021-12-29 08:49:33 -05:00
Thomas Pelletier
8ce5c3d78f
Decoder: time allows extra precision ( #710 )
...
As discussed[1], this change allows times to provide precision beyond the
nanosecond (nine digits fractional part). Extra precision is truncated according
to the TOML specificiation.
[1]: https://github.com/pelletier/go-toml/discussions/707
2021-12-26 17:05:10 +01:00
Thomas Pelletier
177b4a5e53
Decode: allow \r\n as line whitespace before \ ( #709 )
...
Fixes #708
2021-12-26 16:38:15 +01:00
Cameron Moore
5cbdea6192
decode: fix maximum time offset values ( #706 )
...
According to RFC3339 section 5.6, the maximum time offset values for
hours and minutes is 23 and 59, respectively.
2021-12-22 10:29:52 +01:00
Thomas Pelletier
696dd25c17
Decoder: disallow modification of existing table ( #704 )
...
Fixes #703
2021-12-15 11:05:27 -05:00
Thomas Pelletier
facb2b13e8
Decoder: prevent modification of inline tables ( #702 )
...
Fixes #701
2021-12-12 09:43:42 -05:00
Cameron Moore
8bbb519477
Decode: ensure signed exponents don't start with an underscore ( #699 )
2021-12-05 20:02:19 -05:00
Cameron Moore
b37e11d74d
Decode: allow maximum seconds value of 60 ( #700 )
...
RFC3339 allows seconds to be 60 when adding leap seconds
2021-12-05 20:00:42 -05:00
Cameron Moore
6cd86876b8
Decode: ensure signed numbers don't start with an underscore ( #698 )
2021-12-04 16:56:48 -05:00
Cameron Moore
f53bc740c1
Decode: restrict timezone offset values ( #696 )
...
Don't allow hours greater than 24 and minutes greater than 60 per RFC
3339.
2021-12-02 18:59:32 -05:00
Thomas Pelletier
9bf9be681e
Decoder: check for invalid chars in timezone ( #695 )
...
Fixes #694
2021-12-02 09:00:20 -05:00
Thomas Pelletier
c862c344b3
Decoder: allow commas in tags ( #693 )
2021-11-30 21:59:22 -05:00
Thomas Pelletier
3990899d7e
Decoder: check tz has : between hours and minutes ( #691 )
...
Fixes #690
2021-11-30 20:22:11 -05:00
Cameron Moore
4c7a337083
Decoder: fix typo in test description ( #689 )
2021-11-30 15:28:01 -05:00
Thomas Pelletier
bbaae540ce
Decoder: check timezones start with +,-,z,Z ( #688 )
...
Also simplifies local time seconds scanning.
Fixes #686
2021-11-30 13:01:15 -05:00
Thomas Pelletier
ede6445608
Decoder: flag bad \r in literal multiline strings ( #687 )
...
Fixes #685
2021-11-30 10:44:48 -05:00
Thomas Pelletier
b226db6a29
Decoder: show struct field in type mismatch errors ( #684 )
...
The goal is to provide some context as to why the type were mismatched. This
change only works for that case, on structs. This is the same a encoding/json. A
more general solution would be great, but this would require a broader change in
the decoder, which I don't think is necessary at the moment.
Fixes #628
2021-11-24 20:43:56 -05:00
Thomas Pelletier
79e78b234c
Decoder: fix panic on table array behind a pointer ( #682 )
...
Fixes #677
2021-11-24 18:50:04 -05:00
Thomas Pelletier
1b5a25c0ef
Decoder: fail on unescaped \r not followed by \n ( #681 )
...
Fixes #674
2021-11-24 18:11:36 -05:00
Thomas Pelletier
8eae15b2ee
Decoder: validate bounds of day and month in dates ( #680 )
...
Fixes #676
2021-11-24 17:42:01 -05:00
Thomas Pelletier
2b3de620e8
Encoder: try to use pointer type TextMarshaler ( #679 )
...
If a type does not implement the encoding.TextMarshaler interface but
its pointer type does, use it if possible.
Fixes #678
2021-11-24 14:43:49 -05:00
Cameron Moore
8645d6376b
Decoder: flag invalid carriage returns in literal strings ( #673 )
2021-11-23 22:41:59 -05:00
Thomas Pelletier
4dff8eaa4d
Decoder: prevent duplicates of inline tables ( #667 )
...
* seen: prevent duplicates of inline tables
* Provide clearer error message for redefined keys
For example:
``
toml: key b is already defined
```
2021-11-10 10:04:43 -05:00
Cameron Moore
2dbd29a565
parser: Fix missing check for upper exponent ( #665 )
2021-11-09 21:15:23 -05:00
Thomas Pelletier
f27a07d31a
seen: verify arrays ( #663 )
...
Fixes #662
2021-11-09 20:26:30 -05:00
Thomas Pelletier
8683be35f6
seen: check inline tables ( #660 )
...
Fixes #658
2021-11-08 21:53:02 -05:00
Thomas Pelletier
dc1740d473
Decode: code cleanup for struct cache ( #659 )
2021-11-07 18:35:30 -05:00
Thomas Pelletier
11f789ef11
Decode: prevent comments that look like dates to be accepted ( #657 )
...
* parser: fix date detection
When the parser has to decide between parsing and integer or a date, it should
check that all characters are actually acceptable (digits, or date/time
elements).
Fixes #655
2021-11-04 22:06:12 -04:00
Thomas Pelletier
74d21b367f
scanner: handle carriage return in comments ( #656 )
...
Fixes #653
2021-11-04 21:40:16 -04:00
Thomas Pelletier
3dbca20bc9
Decoder: flag invalid carriage returns in strings ( #652 )
...
Fixes #651
2021-11-02 10:02:25 -04:00
Thomas Pelletier
85c0658984
Decode: add missing checks for LocalTime ( #650 )
2021-10-29 22:13:08 -04:00
Thomas Pelletier
3694ae88f6
decode: error on _ before exponent in floats ( #647 )
...
Fixes #646
2021-10-28 20:41:10 -04:00
Thomas Pelletier
c871a61015
unmarshal: use UnmarshalText for any type ( #642 )
...
Not only structs can implement TextUnmarshaler.
Fixes #564
2021-10-28 17:02:47 -04:00
Thomas Pelletier
d0d001625c
unmarshal: don't panic when storing table in slice ( #641 )
...
New error message:
```
toml: cannot store a table in a slice
1| [things]
| ~~~~~~ cannot store a table in a slice
2| foo = "bar"
```
Fixes #623
2021-10-25 16:47:10 -04:00
Thomas Pelletier
64941b99e2
unmarshal: empty document results in map ( #640 )
...
Fixes #602
2021-10-25 15:55:54 -04:00
Thomas Pelletier
4d7c9ddac7
Floats and integers parsing fixes ( #638 )
...
* parser: fix scan of float with exp but no decimal
* decoder: validate leading zeros for decimals
2021-10-22 22:25:56 -04:00
Cameron Moore
a23850f29b
decode: preserve nanosecond precision when decoding time ( #626 )
...
Co-authored-by: Thomas Pelletier <thomas@pelletier.codes >
2021-10-17 20:43:29 -04:00
Johanan Idicula
76f53c857b
unmarshal: validate date ( #622 )
2021-10-17 20:18:20 -04:00
Thomas Pelletier
85f5d567e4
parser: validate invalid ASCII control characters
2021-10-16 07:41:12 -04:00
Thomas Pelletier
cd54472d03
Validate UTF-8 ( #629 )
2021-10-15 19:13:21 -04:00
Riya John
e96746311c
decoder: fix panic date time should have a timezone ( #614 )
...
Fixes #596
Co-authored-by: Thomas Pelletier <thomas@pelletier.codes >
2021-10-06 21:24:25 -04:00
Cameron Moore
476492a85c
unmarshal: support lowercase 'T' and 'Z' in date-time parsing ( #601 )
...
RFC3399 allows for lowercase 't' and 'z' in date-time values.
Fixes #600
2021-09-25 10:02:23 -07:00
Thomas Pelletier
fa56f48daf
parser: don't overflow when parsing bad times ( #593 )
...
Fixes #585
2021-09-09 11:59:37 -04:00