#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: trunk
Keywords: Cc:


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 Changed 16 months ago by pramsey

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.

comment:2 Changed 15 months ago by Algunenano

Seems like the issue comes from ignoring WHITESPACEs in the coordinate declaration and supporting numbers as .5 (0.5):

# select ST_AsEWKT('LINESTRING(.1 .2, .3 .4)'::geometry);
 LINESTRING(0.1 0.2,0.3 0.4)
(1 row)

# select ST_AsEWKT('LINESTRING(.1.2, .3.4)'::geometry);
 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.

comment:3 Changed 15 months ago by Raul Marin

Resolution: fixed
Status: newclosed

In 16662:

Fix WKT parser accepting numbers with multiple dots

Closes #4109
Closes https://github.com/postgis/postgis/pull/277

Note: See TracTickets for help on using tickets.