]> granicus.if.org Git - jq/commitdiff
EOF after newline in string mishandled (fix #951)
authorNicolas Williams <nico@cryptonector.com>
Tue, 22 Sep 2015 04:24:08 +0000 (23:24 -0500)
committerDavid Tolnay <dtolnay@gmail.com>
Wed, 23 Sep 2015 03:11:54 +0000 (20:11 -0700)
src/util.c
tests/shtest

index e18a91b6cab24ff4da1bff94fbe7418fa438490b..3f7cab8de24305c52aecd5c5ed8d7f3f968ceab7 100644 (file)
@@ -435,10 +435,8 @@ jv jq_util_input_next_input(jq_util_input_state *state) {
     } else {
       if (jv_parser_remaining(state->parser) == 0) {
         is_last = jq_util_input_read_more(state);
-        if (is_last && state->buf_valid_len == 0) {
+        if (is_last && state->buf_valid_len == 0)
           value = jv_invalid();
-          break;
-        }
         jv_parser_set_buf(state->parser, state->buf, state->buf_valid_len, !is_last);
       }
       value = jv_parser_next(state->parser);
index 6e7690e4826c7a9e69ad1eaaaa393b62897e340d..1a9561301794ac068172fc6f826ef0478fd49a25 100755 (executable)
@@ -109,10 +109,21 @@ printf '1' | $JQ -ce --seq . > $d/out 2>&1
 cmp $d/out $d/expected
 
 cat > $d/expected <<EOF
+jq: error (at <stdin>:1): Unfinished abandoned text at EOF at line 2, column 0
 EOF
-printf '1\n' | $JQ -cen --seq '[inputs] == []' >/dev/null 2> $d/out
+if printf '1\n' | $JQ -cen --seq '[inputs] == []' >/dev/null 2> $d/out; then
+  printf 'Error expected but jq exited successfully\n' 1>&2
+  exit 2
+fi
 cmp $d/out $d/expected
 
+# Regression test for #951
+printf '"a\n' > $d/input
+if $VALGRIND $Q $JQ -e . $d/input; then
+  printf 'Issue #951 is back?\n' 1>&2
+  exit 2
+fi
+
 ## Test streaming parser
 
 ## If we add an option to stream to the `import ... as $symbol;` directive