[postgis-tickets] r17129 - Move fix further into parser, fix bad test case
Paul Ramsey
pramsey at cleverelephant.ca
Wed Jan 9 12:09:19 PST 2019
Author: pramsey
Date: 2019-01-09 12:09:19 -0800 (Wed, 09 Jan 2019)
New Revision: 17129
Modified:
branches/2.5/NEWS
branches/2.5/liblwgeom/cunit/cu_in_wkt.c
branches/2.5/liblwgeom/cunit/cu_out_x3d.c
branches/2.5/liblwgeom/lwin_wkt_parse.c
Log:
Move fix further into parser, fix bad test case
References #4273
Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS 2019-01-09 19:43:03 UTC (rev 17128)
+++ branches/2.5/NEWS 2019-01-09 20:09:19 UTC (rev 17129)
@@ -25,7 +25,9 @@
- #4276, ST_AsGeoJSON documentation refresh (Darafei Praliaskouski)
+ - #4273, Tighter parsing of WKT (Paul Ramsey)
+
PostGIS 2.5.1
2018/11/18
Modified: branches/2.5/liblwgeom/cunit/cu_in_wkt.c
===================================================================
--- branches/2.5/liblwgeom/cunit/cu_in_wkt.c 2019-01-09 19:43:03 UTC (rev 17128)
+++ branches/2.5/liblwgeom/cunit/cu_in_wkt.c 2019-01-09 20:09:19 UTC (rev 17129)
@@ -67,6 +67,11 @@
static void test_wkt_in_point(void)
{
+ s = "POINT(1 2) foobar";
+ r = cu_wkt_in(s, WKT_SFSQL);
+ CU_ASSERT_STRING_EQUAL("parse error - invalid geometry", r);
+ lwfree(r);
+
s = "POINT(1e700 0)";
r = cu_wkt_in(s, WKT_SFSQL);
CU_TEST ( ! strcmp(r, "POINT(inf 0)") || ! strcmp(r, "POINT(1.#INF 0)") || ! strcmp(r, "POINT(Infinity 0)") );
Modified: branches/2.5/liblwgeom/cunit/cu_out_x3d.c
===================================================================
--- branches/2.5/liblwgeom/cunit/cu_out_x3d.c 2019-01-09 19:43:03 UTC (rev 17128)
+++ branches/2.5/liblwgeom/cunit/cu_out_x3d.c 2019-01-09 20:09:19 UTC (rev 17129)
@@ -77,7 +77,7 @@
/* huge data */
do_x3d3_test(
- "POINT(1E300 -105E-153 4E300)'", "1e+300 0 4e+300", NULL, 0, 0);
+ "POINT(1E300 -105E-153 4E300)", "1e+300 0 4e+300", NULL, 0, 0);
}
Modified: branches/2.5/liblwgeom/lwin_wkt_parse.c
===================================================================
--- branches/2.5/liblwgeom/lwin_wkt_parse.c 2019-01-09 19:43:03 UTC (rev 17128)
+++ branches/2.5/liblwgeom/lwin_wkt_parse.c 2019-01-09 20:09:19 UTC (rev 17129)
@@ -95,16 +95,16 @@
/* Turn on/off verbose parsing (turn off for production) */
int wkt_yydebug = 0;
-/*
-* Error handler called by the bison parser. Mostly we will be
+/*
+* Error handler called by the bison parser. Mostly we will be
* catching our own errors and filling out the message and errlocation
-* from WKT_ERROR in the grammar, but we keep this one
+* from WKT_ERROR in the grammar, but we keep this one
* around just in case.
*/
void wkt_yyerror(__attribute__((__unused__)) const char *str)
{
/* If we haven't already set a message and location, let's set one now. */
- if ( ! global_parser_result.message )
+ if ( ! global_parser_result.message )
{
global_parser_result.message = parser_error_messages[PARSER_ERROR_OTHER];
global_parser_result.errcode = PARSER_ERROR_OTHER;
@@ -137,14 +137,14 @@
/* Set the input text string, and parse checks. */
global_parser_result.wkinput = wktstr;
global_parser_result.parser_check_flags = parser_check_flags;
-
+
wkt_lexer_init(wktstr); /* Lexer ready */
parse_rv = wkt_yyparse(); /* Run the parse */
LWDEBUGF(4,"wkt_yyparse returned %d", parse_rv);
wkt_lexer_close(); /* Clean up lexer */
-
+
/* A non-zero parser return is an error. */
- if ( parse_rv != 0 )
+ if ( parse_rv || global_parser_result.errcode )
{
if( ! global_parser_result.errcode )
{
@@ -153,17 +153,17 @@
global_parser_result.errlocation = wkt_yylloc.last_column;
}
- LWDEBUGF(5, "error returned by wkt_yyparse() @ %d: [%d] '%s'",
- global_parser_result.errlocation,
- global_parser_result.errcode,
+ LWDEBUGF(5, "error returned by wkt_yyparse() @ %d: [%d] '%s'",
+ global_parser_result.errlocation,
+ global_parser_result.errcode,
global_parser_result.message);
-
+
/* Copy the global values into the return pointer */
*parser_result = global_parser_result;
wkt_yylex_destroy();
return LW_FAILURE;
}
-
+
/* Copy the global value into the return pointer */
*parser_result = global_parser_result;
wkt_yylex_destroy();
More information about the postgis-tickets
mailing list