avoid ascii control characters in strings

This commit is contained in:
Dana Jansens 2010-03-24 19:49:23 -04:00
parent 70e819a905
commit 4968f7c62a

View file

@ -96,7 +96,7 @@ static gchar* parse_string(const gchar *in, gboolean locale,
if (!locale) { if (!locale) {
end = in + bytes; end = in + bytes;
for (i = in; i < end; ++i) { for (i = in; i < end; ++i) {
if (*i > 127) { if (*i > 126 || *i < 32) { /* non-control character ascii */
end = i; end = i;
parse_error("Invalid bytes in string", parse, error); parse_error("Invalid bytes in string", parse, error);
break; break;
@ -128,6 +128,10 @@ static gchar* parse_string(const gchar *in, gboolean locale,
} }
else if (*i == '\\') else if (*i == '\\')
backslash = TRUE; backslash = TRUE;
else if (*i >= 127 || *i < 32) { /* avoid ascii control characters */
parse_error("Found control character in string", parse, error);
break;
}
else { else {
memcpy(o, i, next-i); memcpy(o, i, next-i);
o += next-i; o += next-i;