Commit 1ba28a8e authored by Raúl Marín's avatar Raúl Marín

Fix WKT parser accepting numbers with multiple dots

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


git-svn-id: http://svn.osgeo.org/postgis/trunk@16662 b70326c6-7e19-0410-871a-916f4a2858ee
parent 7b9283b8
Pipeline #26327125 passed with stage
in 24 minutes and 45 seconds
......@@ -6,6 +6,8 @@ New since PostGIS 2.5.0beta1
- #4120, ST_AsMVTGeom: Clip using tile coordinates (Raúl Marín).
- #4132, ST_Intersection on Raster now works without throwing TopologyException
(Vinícius A.B. Schmidt, Darafei Praliaskouski)
- #4109, Fix WKT parser accepting and interpreting numbers numbers with
multiple dots (Raúl Marín, Paul Ramsey)
See PostGIS 2.5.0 section for full details
......
......@@ -346,6 +346,40 @@ static void test_wkt_in_errlocation(void)
}
static void test_wkt_double(void)
{
LWGEOM_PARSER_RESULT p;
int rv = 0;
char *wkt = 0;
wkt = "LINESTRING(1.1.1, 2.2.2)";
lwgeom_parser_result_init(&p);
rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL);
CU_ASSERT_EQUAL( rv, LW_FAILURE );
wkt = "LINESTRING(1.1 .1, 2.2 .2)";
lwgeom_parser_result_init(&p);
rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL);
CU_ASSERT_EQUAL( rv, LW_SUCCESS );
wkt = "LINESTRING( 1.1 .1 , 2.2 .2 )";
lwgeom_parser_result_init(&p);
rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL);
CU_ASSERT_EQUAL( rv, LW_SUCCESS );
wkt = "LINESTRING(\n1.1\n.1,\n2.2\n.2\n)";
lwgeom_parser_result_init(&p);
rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL);
CU_ASSERT_EQUAL( rv, LW_SUCCESS );
wkt = "LINESTRING(1.1\t.1\t,\t2.2\t.2\t)";
lwgeom_parser_result_init(&p);
rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL);
CU_ASSERT_EQUAL( rv, LW_SUCCESS );
lwgeom_parser_result_free(&p);
}
/*
** Used by test harness to register the tests in this file.
*/
......@@ -368,4 +402,5 @@ void wkt_in_suite_setup(void)
PG_ADD_TEST(suite, test_wkt_in_tin);
PG_ADD_TEST(suite, test_wkt_in_polyhedralsurface);
PG_ADD_TEST(suite, test_wkt_in_errlocation);
}
PG_ADD_TEST(suite, test_wkt_double);
}
\ No newline at end of file
This diff is collapsed.
......@@ -48,9 +48,10 @@ static void wkt_lexer_unknown()
%%
-?(([0-9]+\.?)|([0-9]*\.?[0-9]+)([eE][-+]?[0-9]+)?) {
-?(([0-9]+\.?)|([0-9]*\.?[0-9]+)([eE][-+]?[0-9]+)?)[ \,\)\t\n\r] {
LWDEBUG(5,"DOUBLE");
wkt_yylval.doublevalue = atof(wkt_yytext);
wkt_yylval.doublevalue = atof(wkt_yytext);
yyless(wkt_yyleng-1);
return DOUBLE_TOK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment