YaML: escape exclamation marks to avoid issues with compliant parsers
and added some support for reading such escaped characters.
This commit is contained in:
committed by
Peter Feerick
parent
1103a3c842
commit
66932626d5
@@ -437,7 +437,7 @@ bool w_swtchSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* o
|
||||
{
|
||||
int32_t sval = yaml_to_signed(val, node->size);
|
||||
if (sval < 0) {
|
||||
wf(opaque, "!", 1);
|
||||
wf(opaque, "\\!", 2);
|
||||
sval = abs(sval);
|
||||
}
|
||||
|
||||
|
||||
@@ -763,7 +763,7 @@ static bool w_swtchSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf,
|
||||
{
|
||||
int32_t sval = yaml_to_signed(val, node->size);
|
||||
if (sval < 0) {
|
||||
wf(opaque, "!", 1);
|
||||
wf(opaque, "\\!", 2);
|
||||
sval = abs(sval);
|
||||
}
|
||||
|
||||
|
||||
@@ -213,6 +213,10 @@ YamlParser::parse(const char* buffer, unsigned int size)
|
||||
state = ps_ValQuo;
|
||||
break;
|
||||
}
|
||||
if (*c == '\\') {
|
||||
state = ps_ValEsc;
|
||||
break;
|
||||
}
|
||||
CONCAT_STR(scratch_buf, scratch_len, *c);
|
||||
break;
|
||||
|
||||
@@ -284,6 +288,15 @@ YamlParser::parse(const char* buffer, unsigned int size)
|
||||
state = ps_ValQuo;
|
||||
break;
|
||||
}
|
||||
if (*c == '\\') {
|
||||
state = ps_ValEsc;
|
||||
break;
|
||||
}
|
||||
CONCAT_STR(scratch_buf, scratch_len, *c);
|
||||
break;
|
||||
|
||||
case ps_ValEsc:
|
||||
state = ps_Val;
|
||||
CONCAT_STR(scratch_buf, scratch_len, *c);
|
||||
break;
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class YamlParser
|
||||
ps_AttrSP,
|
||||
ps_Sep,
|
||||
ps_Val,
|
||||
ps_ValEsc,
|
||||
ps_ValQuo,
|
||||
ps_ValEsc1,
|
||||
ps_ValEsc2,
|
||||
|
||||
Reference in New Issue
Block a user