From 3c68ae0dcc42df25e018b631eadd99aca96103fd Mon Sep 17 00:00:00 2001 From: leitner Date: Mon, 13 Mar 2017 13:46:37 +0000 Subject: [PATCH] scan_jsonescape ends when it sees an unescaped " --- GNUmakefile | 2 +- textcode/scan_jsonescape.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 83b8b65..925609c 100644 --- a/GNUmakefile +++ b/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)) diff --git a/textcode/scan_jsonescape.c b/textcode/scan_jsonescape.c index 7fb8b41..0ba88b8 100644 --- a/textcode/scan_jsonescape.c +++ b/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; }