Comment 7 for bug 1940283

Revision history for this message
Andrew Johnson (anj) wrote :

This change

diff --git a/modules/database/src/ioc/dbStatic/dbLex.l b/modules/database/src/ioc/dbStatic/dbLex.l
index 33185133c..19812c9da 100644
--- a/modules/database/src/ioc/dbStatic/dbLex.l
+++ b/modules/database/src/ioc/dbStatic/dbLex.l
@@ -130,6 +130,14 @@ static int yyreset(void)

 <INITIAL,JSON>{whitespace} ;

+<JSON>{doublequote}({stringchar}|{escape})*{doublequote} { /* bad JSON */
+ yyerrorAbort("Bad character in JSON string");
+<JSON>{singlequote}({stringchar}|{escape})*{singlequote} { /* bad JSON */
+ yyerrorAbort("Bad character in JSON string");
     char message[40];
     YY_BUFFER_STATE *dummy=0;

results in this error message:

woz$ softIoc -d ~/db/test.db
Error: Bad character in JSON string
 at or before ""a b"" in file "/Users/anj/db/test.db" line 5
Error: Invalid character ')'
Error: syntax error
dbLoadRecords: failed to load '/Users/anj/db/test.db'
Error: Failed to load: /Users/anj/db/test.db

which is better, although not perfect because of the messages afterwards. Instead of just calling yyerrorAbort() it could take a look at the string (found in yytext) and explain what's wrong with it. Contributions welcomed...