Skip to content
Myr

Fix hang for slurped inputs with trailing newline

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by William Langford · committed by William Langford · parent f06deb8 · Browse files · 2 files+6 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−4 removed

  • tests:+2 added−0 removed
  • other:+4 added−4 removed

2 files+6 added−4 removed

modified:src/util.c+4 added-4 removed
440 unmodified lines
441 jv_parser_set_buf(state->parser, state->buf, state->buf_valid_len, !is_last);442 }443 value = jv_parser_next(state->parser);444 if (jv_is_valid(state->slurped)) {445 // When slurping an input that doesn't have a trailing newline,446 // we might have more than one value on the same line, so let's check447 // to see if we have more data to parse.448 has_more = jv_parser_remaining(state->parser);449 if (jv_is_valid(value)) {450 state->slurped = jv_array_append(state->slurped, value);451 value = jv_invalid();448 // When slurping an input that doesn't have a trailing newline,449 // we might have more than one value on the same line, so let's check450 // to see if we have more data to parse.451 has_more = jv_parser_remaining(state->parser);452 } else if (jv_invalid_has_msg(jv_copy(value)))453 return value; // Not slurped parsed input454 } else if (jv_is_valid(value) || jv_invalid_has_msg(jv_copy(value))) {455 return value;
10 unmodified lines
modified:tests/shtest+2 added
124 unmodified lines
125# Regression test for #1534126echo "[1,2,3,4]" > $d/expected127printf "[1,2][3,4]" | $JQ -cs add > $d/out 2>&1128cmp $d/out $d/expected129printf "[1,2][3,4]\n" | $JQ -cs add > $d/out 2>&1130cmp $d/out $d/expected131132133## Test streaming parser134
175 unmodified lines