Add support for hex escapes to the dbStatic lexer

Only translate escaped chars that are inside a jsonSTRING value.
This commit is contained in:
Andrew Johnson
2020-08-04 23:31:11 -05:00
parent c1152f94fd
commit b34d3c83fc
2 changed files with 9 additions and 4 deletions

View File

@@ -20,10 +20,11 @@ bareword [a-zA-Z0-9_\-+:.\[\]<>;]
punctuation [:,\[\]{}]
normalchar [^"\\\0-\x1f]
barechar [a-zA-Z0-9_\-+.]
escapedchar ({backslash}["\\/bfnrt])
escapedchar ({backslash}[^ux1-9])
hexdigit [0-9a-fA-F]
latinchar ({backslash}"x"{hexdigit}{2})
unicodechar ({backslash}"u"{hexdigit}{4})
jsonchar ({normalchar}|{escapedchar}|{unicodechar})
jsonchar ({normalchar}|{escapedchar}|{latinchar}|{unicodechar})
jsondqstr ({doublequote}{jsonchar}*{doublequote})
sign ([+-]?)

View File

@@ -1172,12 +1172,14 @@ static void dbRecordField(char *name,char *value)
yyerror(NULL);
return;
}
if (*value == '"') {
/* jsonSTRING values still have their quotes */
value++;
value[strlen(value) - 1] = 0;
dbTranslateEscape(value, value); /* in-place; safe & legal */
}
dbTranslateEscape(value, value); /* in-place; safe & legal */
status = dbPutString(pdbentry,value);
if (status) {
char msg[128];
@@ -1203,12 +1205,14 @@ static void dbRecordInfo(char *name, char *value)
if (duplicate) return;
ptempListNode = (tempListNode *)ellFirst(&tempList);
pdbentry = ptempListNode->item;
if (*value == '"') {
/* jsonSTRING values still have their quotes */
value++;
value[strlen(value) - 1] = 0;
dbTranslateEscape(value, value); /* in-place; safe & legal */
}
dbTranslateEscape(value, value); /* yuck: in-place, but safe */
status = dbPutInfo(pdbentry,name,value);
if (status) {
epicsPrintf("Can't set \"%s\" info \"%s\" to \"%s\"\n",