Browse Source

scan_jsonescape ends when it sees an unescaped "

master
Felix von Leitner 5 years ago
parent
commit
b2efd1c0a3
  1. 2
      GNUmakefile
  2. 4
      textcode/scan_jsonescape.c

2
GNUmakefile

@ -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))

4
textcode/scan_jsonescape.c

@ -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