Skip to content

Commit

Permalink
double quotes at begin of string
Browse files Browse the repository at this point in the history
  handling of double quotes surrounding string was naive; fix that
  added test 16
	closes #47
  • Loading branch information
jpmens committed Jan 19, 2017
1 parent 2779022 commit 935a324
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions jo.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ JsonNode *vnode(char *str, int flags)
/* If str begins with a double quote, keep it a string */

if (*str == '"') {
#if 0
char *bp = str + strlen(str) - 1;

if (bp > str && *bp == '"')
*bp = 0; /* Chop closing double quote */
return json_mkstring(str + 1);
#endif
return json_mkstring(str);
}

char *endptr;
Expand Down
2 changes: 1 addition & 1 deletion tests/jo.11.exp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[true,false,null,"true","false","null"]
[true,false,null,"\"true\"","\"false\"","\"null\""]
1 change: 1 addition & 0 deletions tests/jo.16.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"msg":"\"All's Well\", she said."}
7 changes: 7 additions & 0 deletions tests/jo.16.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# quotes in quotes
tmp=/tmp/jo.$$
trap "rm -f $tmp; exit" 0 1 2 15

${JO:-jo} msg='"All'\''s Well", she said.'


0 comments on commit 935a324

Please sign in to comment.