Opened 7 years ago
Closed 6 years ago
#4109 closed defect (fixed)
WKT parser accepting and interpreting numbers with multiple dots
Reported by: | strk | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.5.0 |
Component: | postgis | Version: | master |
Keywords: | Cc: |
Description
I think the following query should raise an exception rather than giving a debatable interpretation:
select ST_AsEWKT('LINESTRING(1.1.1, 2.2.2)'::geometry); LINESTRING(1.1 0.1,2.2 0.2)
Not sure how back this bug goes
Change History (3)
comment:1 by , 7 years ago
comment:2 by , 6 years ago
Seems like the issue comes from ignoring WHITESPACE
s in the coordinate declaration and supporting numbers as .5
(0.5):
# select ST_AsEWKT('LINESTRING(.1 .2, .3 .4)'::geometry); st_asewkt ----------------------------- LINESTRING(0.1 0.2,0.3 0.4) (1 row) # select ST_AsEWKT('LINESTRING(.1.2, .3.4)'::geometry); st_asewkt ----------------------------- LINESTRING(0.1 0.2,0.3 0.4) (1 row)
This probably goes back to 2010.
I've given it a try in https://github.com/postgis/postgis/pull/277
After the change:
ERROR: parse error - invalid geometry LINE 1: select ST_AsEWKT('LINESTRING(.1.2, .3.4)'::geometry); ^ HINT: "LINESTRING(.1.2," <-- parse error at position 16 within geometry
The main problem is that some other matching rules had to be modified to now accept optional whitespaces before or after the main string. It'd nice if someone with experience with Bison (or other parsers) could have a look to see how it can be improved, and also because I've relied on the tests to check if anything was broken.
Probably all the way back to the beginning, or at least to the introduction of flex, I think, as I'd guess it's an issue with the lexer.