scan_jsonescape ends when it sees an unescaped "

master
leitner 8 years ago
parent da2a8332fe
commit 3c68ae0dcc

@ -225,7 +225,7 @@ install-man:
install -d $(DESTDIR)$(MAN3DIR)
install -m 644 $(wildcard */*.3) $(DESTDIR)$(MAN3DIR)
install: install-inc install-man install-lib
install: headers install-inc install-man install-lib
uninstall:
rm -f $(patsubst %.h,$(INCLUDEDIR)/%.h,$(INCLUDES))

@ -11,6 +11,9 @@ size_t scan_jsonescape(const char *src,char *dest,size_t *destlen) {
for (i=0; s[i]; ++i) {
if ((c=s[i])=='\\') {
switch (s[i+1]) {
case '"':
if (prev!=(unsigned int)-1) return 0; // lead surrogate not followed by tail surrogate
goto done;
case '\\':
if (prev!=(unsigned int)-1) return 0; // lead surrogate not followed by tail surrogate
// c='\\'; // c already is backslash
@ -54,6 +57,7 @@ size_t scan_jsonescape(const char *src,char *dest,size_t *destlen) {
if (dest) dest[written]=c;
++written;
}
done:
*destlen=written;
return i;
}

Loading…
Cancel
Save