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
This commit is contained in:
@@ -1569,6 +1569,30 @@ B = "data"`,
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "comment that looks like a date",
|
||||
input: "a=19#9-",
|
||||
gen: func() test {
|
||||
doc := map[string]interface{}{}
|
||||
|
||||
return test{
|
||||
target: &doc,
|
||||
expected: &map[string]interface{}{"a": int64(19)},
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "comment that looks like a date",
|
||||
input: "a=199#-",
|
||||
gen: func() test {
|
||||
doc := map[string]interface{}{}
|
||||
|
||||
return test{
|
||||
target: &doc,
|
||||
expected: &map[string]interface{}{"a": int64(199)},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, e := range examples {
|
||||
|
||||
Reference in New Issue
Block a user