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

ion-js parses malformed timestamps as valid Ion #724

Open
popematt opened this issue Sep 8, 2022 · 0 comments
Open

ion-js parses malformed timestamps as valid Ion #724

popematt opened this issue Sep 8, 2022 · 0 comments
Labels

Comments

@popematt
Copy link
Contributor

popematt commented Sep 8, 2022

The Ion Spec says

In the text notation, timestamp values must be followed by one of the fifteen numeric stop-characters: {}[](),\"\'\ \t\n\r\v\f.

However, ion-js allows almost any character after a timestamp when the timestamp has a precision of year or month. Here are some examples of invalid Ion that are incorrectly accepted by ion-js.

Invalid Input Parsed As
2001TZ 2001T 'Z'
2001T+inf 2001T +inf
2001-01T10.00 2001-01T 10.00
(2001-01TZ+10) ( 2001-01T 'Z' '+' 10 )
(2001-01T.0.10) ( 2001-01T '.' 0.10 )
2001-01Tnull.bool 2001-01T null.bool

The probable cause is that there is no check for a numeric stop character after the T for the YYYY and YYYY-MM branches of _readTimestamp().
https://github.com/amzn/ion-js/blob/b5f6ab34707b57767b54f55845ae97ebb77b248f/src/IonParserTextRaw.ts#L1093-L1110

@popematt popematt added the bug label Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant