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

Timestamp Parsing of YY-MM-DDT Fails As Invalid #194

Open
almann opened this issue Aug 15, 2020 · 1 comment
Open

Timestamp Parsing of YY-MM-DDT Fails As Invalid #194

almann opened this issue Aug 15, 2020 · 1 comment

Comments

@almann
Copy link
Contributor

almann commented Aug 15, 2020

The following test fails:

TEST(IonTimestamp, YYMMDDT) {
    ION_TIMESTAMP timestamp;
    SIZE chars_used;

    std::string lit("2020-08-10T");
    ION_ASSERT_OK(ion_timestamp_parse(
        &timestamp, (char *)lit.c_str(), (SIZE) (lit.size() + 1), &chars_used, &g_IonEventDecimalContext
    ));
    ASSERT_EQ(lit.size(), chars_used);
}

ion_timestamp_parse requires a null terminated string and appears to expects the buffer to be a length inclusive of the null termination (there is explicit code to look for the null character within the length specified).

The following works (note the lack of T):

TEST(IonTimestamp, YYMMDD) {
    ION_TIMESTAMP timestamp;
    SIZE chars_used;

    std::string lit("2020-08-10");
    ION_ASSERT_OK(ion_timestamp_parse(
        &timestamp, (char *)lit.c_str(), (SIZE) (lit.size() + 1), &chars_used, &g_IonEventDecimalContext
    ));
    ASSERT_EQ(lit.size(), chars_used);
}

I suspect the problem (but have not confirmed) that the problem is at ion_timestamp L561, where it should be going to end_of_days, not end_of_time.

@almann
Copy link
Contributor Author

almann commented Aug 15, 2020

I will add that I believe this is an edge case where a timestamp is at the end of a buffer. There is a potential issue with the timestamp parsing routine requiring the \0 termination (so that might be the larger issue here), it should not be required due to the way Ion parsing routines work (they take a BYTE * and length irrespective of nul termination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant