DateTime.parseDateTimeString will create a non-sensical timestamp for 14-character epoch-like values that use more than one period #724

Closed
ctiwald opened this Issue Mar 8, 2016 · 5 comments

Projects

None yet

3 participants

@ctiwald
ctiwald commented Mar 8, 2016

Noticed this while mucking around with a tool that fronts the TSDB API (i.e. I was trying to clone TSDB's timestamp validation):

https://github.com/OpenTSDB/opentsdb/blob/master/src/utils/DateTime.java#L124-L129

That logic will incorrectly pass a 14-character timestamp that contains a . at the 10th character, but also contains another .:

1234567890.2.4

for example.

Notably, this will convert to "123456789024" on the '.' replace, rather than erroring as it should.

I'm happy to submit a patch for this, but thought I'd check first to see how much you all care :-).

@ctiwald ctiwald changed the title from DateTime.parseDateTimeString will choke on a 14-character epoch-like timestamp with more than one period to DateTime.parseDateTimeString will create a non-sensical timestamp for 14-character epoch-like values that use more than one period Mar 8, 2016
@manolama
Member

Ah good catch, if you'd like submit a PR I'll get it merged in. Thanks!

@manolama manolama added the bug label Mar 14, 2016
@johann8384 johann8384 added this to the v2.3.0 milestone Mar 19, 2016
@johann8384 johann8384 added a commit to johann8384/opentsdb that referenced this issue Mar 23, 2016
@johann8384 johann8384 Added check for malformed, double dot timestamp
Fixes #724
6299ae0
@johann8384 johann8384 self-assigned this Mar 23, 2016
@johann8384
Member

Fixed in #739

@johann8384 johann8384 closed this Mar 23, 2016
@ctiwald
ctiwald commented Mar 23, 2016

Errrr... am I misunderstanding the fix or does it only address cases where there are exactly two .? You could have three, or four, or...

@johann8384
Member

You're right, I was in a rush. Other forms of malformed timestamps could still slip through the mix.

@johann8384 johann8384 reopened this Mar 23, 2016
@johann8384 johann8384 added a commit to johann8384/opentsdb that referenced this issue Mar 23, 2016
@johann8384 johann8384 Updated regex to match dotted timestamp
        1234567890.2.3 - no match
        1234.56789.1234 - no match
        1234567890.1234 - matches
        1234.567890.2..3 - no match
        1234567890.2..3 - no match

Fixes #724
0075c09
@johann8384
Member

As soon as Travis is done I'll merge the fixed-fix. #742

@johann8384 johann8384 closed this Mar 23, 2016
@johann8384 johann8384 added a commit to johann8384/opentsdb that referenced this issue Mar 24, 2016
@johann8384 johann8384 Updated regex to match dotted timestamp
        1234567890.2.3 - no match
        1234.56789.1234 - no match
        1234567890.1234 - matches
        1234.567890.2..3 - no match
        1234567890.2..3 - no match

Fixes #724
927b50d
@manolama manolama added a commit that referenced this issue Oct 8, 2016
@johann8384 @manolama johann8384 + manolama Updated regex to match dotted timestamp
        1234567890.2.3 - no match
        1234.56789.1234 - no match
        1234567890.1234 - matches
        1234.567890.2..3 - no match
        1234567890.2..3 - no match

Fixes #724
24ed995
@johann8384 johann8384 added a commit to johann8384/opentsdb that referenced this issue Dec 5, 2016
@johann8384 johann8384 Added check for malformed, double dot timestamp
Fixes #724
ccf05a9
@johann8384 johann8384 added a commit to johann8384/opentsdb that referenced this issue Dec 5, 2016
@johann8384 johann8384 Updated regex to match dotted timestamp
        1234567890.2.3 - no match
        1234.56789.1234 - no match
        1234567890.1234 - matches
        1234.567890.2..3 - no match
        1234567890.2..3 - no match

Fixes #724
a192f73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment