Commit 074a463b authored by Paul Ramsey's avatar Paul Ramsey

Move fix further into parser, fix bad test case

References #4273


git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@17129 b70326c6-7e19-0410-871a-916f4a2858ee
parent 63584069
Pipeline #42766321 passed with stage
in 22 minutes and 48 seconds
......@@ -25,6 +25,8 @@ XXXX/XX/XX
- #4276, ST_AsGeoJSON documentation refresh (Darafei Praliaskouski)
- #4273, Tighter parsing of WKT (Paul Ramsey)
PostGIS 2.5.1
2018/11/18
......
......@@ -67,6 +67,11 @@ static char* cu_wkt_in(char *wkt, uint8_t variant)
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)") );
......
......@@ -77,7 +77,7 @@ static void out_x3d3_test_precision(void)
/* 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);
}
......
......@@ -95,16 +95,16 @@ LWGEOM_PARSER_RESULT global_parser_result;
/* 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 @@ int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int pars
/* 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 @@ int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int pars
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();
......
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