mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Abort expression parsing after encountering a maximum of 10 errors
Fixes #19480
This commit is contained in:
parent
9db6d94e04
commit
3c8b156c58
@ -31,6 +31,9 @@
|
||||
// don't redeclare malloc/free
|
||||
#define YYINCLUDED_STDLIB_H 1
|
||||
|
||||
// maximum number of errors encountered before parser aborts
|
||||
#define MAX_ERRORS 10
|
||||
|
||||
struct expression_parser_context;
|
||||
#include "qgsexpressionparser.hpp"
|
||||
|
||||
@ -177,7 +180,10 @@ root: expression { parser_ctx->rootNode = $1; }
|
||||
| error expression
|
||||
{
|
||||
delete $2;
|
||||
yyerrok;
|
||||
if ( parser_ctx->parserErrors.count() < MAX_ERRORS )
|
||||
yyerrok;
|
||||
else
|
||||
YYABORT;
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -287,6 +287,14 @@ class TestQgsExpression: public QObject
|
||||
QCOMPARE( exp.parserErrors().first().lastColumn, lastColumn );
|
||||
}
|
||||
|
||||
void max_errors()
|
||||
{
|
||||
QgsExpression e( "wkt_geom	OBJECTID	id	a	b	c	d	e	f	g	h	i	j	k	l	m	n	o	p	q	r	" );
|
||||
QVERIFY( e.hasParserError() );
|
||||
// want parsing to abort after a maximum of 10 errors
|
||||
QCOMPARE( e.parserErrors().count(), 10 );
|
||||
}
|
||||
|
||||
void parsing_with_locale()
|
||||
{
|
||||
// check that parsing of numbers works correctly even when using some other locale
|
||||
|
Loading…
x
Reference in New Issue
Block a user