1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

1563 Commits

Author SHA1 Message Date
27a4d5757e Require a main program (fix #2785) 2023-08-01 23:06:01 -05:00
044b38595c NEWS.md - sub and gsub (#2809) 2023-08-02 08:38:27 +09:00
161ab0402b Fix typo in CI env vars for Linux build (#2810)
For some reason, the env vars are set correctly without refering the variable in `matrix` case-sensitvely:

```
2023-08-01T05:05:58.4626090Z env:
2023-08-01T05:05:58.4626367Z   AR: arm-linux-gnueabihf-ar
2023-08-01T05:05:58.4626690Z   CHOST: arm-linux-gnueabihf
2023-08-01T05:05:58.4626961Z   CC: arm-linux-gnueabihf-gcc
2023-08-01T05:05:58.4627332Z   CPP: arm-linux-gnueabihf-cpp
2023-08-01T05:05:58.4627662Z   CXX: arm-linux-gnueabihf-g++
```

For clarify, we update them to match the definitions. Besides, `CXX` is
not needed and removed.
2023-08-01 07:32:52 -07:00
29698118c5 Update download page with new release key 2023-07-31 23:59:09 -05:00
96263f2e4b Don't unnecessarily ignore missing-field-initializers warnings 2023-07-31 23:16:02 -05:00
90a6b2d9e6 Re-generate src/parser.[ch] 2023-07-31 20:04:41 -05:00
4d4c17ca6a Simple and efficient implementation of walk/1 (#2795) 2023-08-01 07:54:21 +09:00
0f80921268 Fix constant folding of division and reminder with zero divisor
Previously constant folding of zero division (e.x. 1/0) produces a
compile error. This was incorrectly implemented by checking if the
division result is infinite, so produces wrong results compared to the
query where no constant folding is processed (e.x. 1e308/0.1). This
patch delays the operation when the divisor is zero. This makes the
results more consistent, but changes the exit code on zero division from
3 to 5. Also 0/0 now produces the zero division error, not NaN.

This patch also fixes the modulo operation. Previously constant folding
logic does not take care of the % operator, but now it folds if the both
dividend and divisor are safe numbers to cast to the integer type, and
the divisor is not zero. This patch also fixes some code that relies on
undefined cast behaviors in C. The modulo operation produces NaN if
either the dividend or divisor is NaN.
2023-07-31 15:39:13 -05:00
6716e23ae6 Declare cfunction.fptr as jv (*)() to avoid having to cast everywhere
You only need to specify the return type in a function pointer
declaration in C.

If you use () in the declaration, the function pointer can be called
with any arguments, and the type of the arguments is decided for each
function call based on the types of the arguments used for the call.
(To declare a function pointer for a function with no arguments, you use
`(void)'.)

Since all the cfunction structs have a  fptr  that points to a functions
that return jv, not void, we can we can just declare cfunction.fptr as
jv (*)()  and avoid having those annoying and technically not C-standard
compliant casts everywhere.
2023-07-31 15:28:01 -05:00
f61f842ad0 Massage --help text to use max 72 characters width 2023-07-31 18:05:35 +02:00
69deec63e5 Add new release public key 2023-07-31 10:12:18 -05:00
77c4c8afc5 Update signatures of 1.7rc1 2023-07-31 09:31:05 -05:00
c8e28da129 Redesign website (#2628)
* Bump up Bootstrap to v5.3.1, Bootstrap Icon to v1.10.5.
* Use autoComplete.js to drop dependency on jQuery and typeahead.js.
* Support dark mode.
* New svg logo and icon with responsive color mode support.
* Normalize section ids to lower kebab-case for easiness of linking.
* Use relative paths for links for local development (--root /output).
* Various markup cleanups and accessibility improvements.
2023-07-31 09:52:52 +09:00
4af3f99728 Update bug_report.md with Discord link jq-1.7rc1 2023-07-30 04:28:38 +02:00
82f7f772e6 Redirect questions to Discord
We now have an official Discord server and most maintainers are hanging
out there. It would be a good idea to redirect questions to Discord.
2023-07-30 04:28:38 +02:00
f733a1535e Use -Wno-cast-function-type to quiet many warnings 2023-07-30 04:25:54 +02:00
c8b30dff4a Add JQ_FALLTHROUGH and use it to quiet warnings 2023-07-30 04:25:54 +02:00
a6eb055c47 Fix typo in manual: "-seq" => "--seq" 2023-07-29 18:27:59 -05:00
ee2a215f2e Backfill with references in NEWS.md (#2788)
Backfill with references to PRs & issues in NEWS.md
2023-07-29 07:38:08 -07:00
70bbd10b0b NEWS.md: tweaks
correct grammar, add attributions, clarify abs
2023-07-28 17:25:41 -05:00
28af007518 Replace NEWS with NEWS.md with more details and examples
Changes mentioned based on picking user facing changes from:
git log --oneline -r master...jq-1.6 | grep -v Merge
2023-07-28 13:43:14 -05:00
336c3deb8a Test negative indices in path expressions 2023-07-28 12:34:26 -05:00
086a156ec3 Allow .[-1] in path expressions 2023-07-28 12:34:26 -05:00
d319eb2187 Fix PR creation by using fully qualified refname on release 2023-07-28 17:47:51 +09:00
17889a1a85 Fix memory leak for { $foo: bar }
{ BINDING: ExpD } wasn't freeing BINDING.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60865
2023-07-27 20:59:35 -05:00
5b9d0750db Fix PR creation by specifying the branch on release 2023-07-28 10:25:06 +09:00
b33725c96e Fix gh pr create option on release 2023-07-28 10:04:35 +09:00
72f147e82e Fix release job to create a pull request for signatures 2023-07-27 19:18:16 -05:00
4160a36fb5 Commit GPG signatures on release 2023-07-27 17:01:24 -05:00
668607e305 Enable gamma, drem on macOS 2023-07-26 23:56:01 -05:00
a1e791acf8 Rename --nul-output to --raw-output0, abort on string containing NUL
The option naming --nul-output was confusing, especially when we have a
similar option for input stream in the future (--nul-input vs --null-input).
Based on the observation of other command line tools, we rename the option
to --raw-output0. We also drop the short option -0 to avoid confusion on
introducing the NUL-delimited input option.

Unlike the other command line tools outputting file names with NUL delimiter,
jq deals with JSON, and its strings may contain NUL character. To protect
users from the risk of injection attacks, we abort the program and print an
error message before outputting strings including NUL character. Closes #2683.
2023-07-26 23:55:00 -05:00
13fbe98dff manual.yml: remove contingent tests
Also clarify non-prescriptive nature of some tests in jq.test
2023-07-25 23:43:57 -05:00
7b725378b9 builtin.jq: naive abs/0
manual.yml explains that the def is naive, and mentions fabs, etc.
2023-07-25 23:43:57 -05:00
3a1ba0c42d Only care about RS when parsing with --seq
RS should only only have special meaning when parsing json-seq.
Before this fix, RS was sometimes treated as a value terminator, causing
weird results.

Bug discovered by OSS fuzz.
Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60835
2023-07-25 16:42:32 -05:00
ae95864b6b Make sure to free default @text format on error
It seems that bison doesn't call destructors for mid-rule action
components on error, since it does not know their type.

A mid-rule action was used to allocate the "text" string used as format
by string literals without a format, which would leak on error.
This patch replaces it with a new NoFormat component of type <literal>.
Now bison will call jv_free() on that string after a syntax error.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60836

  $ ./jq '"'
  jq: error: syntax error, unexpected end of file, expecting QQSTRING_TEXT or QQSTRING_INTERP_START or QQSTRING_END (Unix shell quoting issues?) at <top-level>, line 1:
  "
  jq: 1 compile error

  =================================================================
  ==1495450==ERROR: LeakSanitizer: detected memory leaks

  Direct leak of 21 byte(s) in 1 object(s) allocated from:
      #0 0x7fc21aee1359 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
      #1 0x557ccb6ff608 in jv_mem_alloc src/jv_alloc.c:141

  SUMMARY: AddressSanitizer: 21 byte(s) leaked in 1 allocation(s).
2023-07-25 14:51:58 -05:00
a949745059 implode: Better invalid input validation and handling
Error on non-number and nan codepoint, would asserd before
Replace negative codepoint and surrogate range with unicode replacement character, would assert before

Fixes #1160
2023-07-25 13:38:41 -05:00
a29ac81de1 Remove deprecated --argfile option 2023-07-25 10:21:01 -05:00
bb8221efdc Align prompt in help example
Was accidentally unaligned in #2747

Now looks like this:

Example:

	$ echo '{"foo": 0}' | jq .
	{
	  "foo": 0
	}

Before looks like this:

Example:

	 $ echo '{"foo": 0}' | jq .
	{
		"foo": 0
	}
2023-07-25 15:10:50 +02:00
4705a22c7d Reorder the command line options in the manual (#2766) 2023-07-25 15:24:54 +09:00
8f49600a6b builtin.jq: simpler and faster transpose (#2758) 2023-07-25 09:12:23 +09:00
330559643a Run autoconf -i in the Build step of the scanbuild workflow
Fixup from 54fef09ac39d6fb003367d65709349c43078405e
2023-07-24 18:55:48 +02:00
cca0087ee6 Test that jq works in threads
This patch implements test that searches a key in simple
json in pthread.
2023-07-24 11:55:15 -05:00
2dbae5610b Fix segmentation fault when using jq in threads
In previous code nomem_handler in jv_alloc.c is called only once
and therefore the structure is not initialized for second and
following threads.

This leads to segmentation fault in multi-threading environment.

This patch moves initialization of nomem_handler out of the
pthread_once call.
2023-07-24 11:55:15 -05:00
5300fbda58 Add decnum workflow to test building without decNumber support 2023-07-24 11:53:51 -05:00
c4d5ba954d Improve USE_DECNUM check position 2023-07-24 11:53:51 -05:00
54fef09ac3 Make maintainer-mode default to disabled
This makes the standard build instructions a bit easier,
just ./configure, and also requires less tools installed (bison).

Also i think few people probably want to generate the lexer and paser code.
2023-07-24 11:26:17 -05:00
4cc99831e4 Free expected value on invalid actual for test
valgrind (3.19.0) locally on macOS docker container seems to detect this leak but not CI.

$ cat modulemeta.test
modulemeta | .deps |= length
"c"
{"whatever":null,"deps":6}

$ valgrind --error-exitcode=1 --leak-check=full -q ./jq --run-tests < modulemeta.test
Test #1: 'modulemeta | .deps |= length' at line number 1
*** Insufficient results for test at line number 3: modulemeta | .deps |= length
0 of 1 tests passed (0 malformed, 0 skipped)
==14129== 482 (392 direct, 90 indirect) bytes in 1 blocks are definitely lost in loss record 7 of 8
==14129==    at 0x48407B4: malloc (vg_replace_malloc.c:381)
==14129==    by 0x13BC78: jv_mem_alloc (jv_alloc.c:122)
==14129==    by 0x1371C6: jvp_object_new (jv.c:1521)
==14129==    by 0x145840: parse_token (jv_parse.c:167)
==14129==    by 0x145840: scan (jv_parse.c:684)
==14129==    by 0x145840: jv_parser_next (jv_parse.c:793)
==14129==    by 0x1463CB: jv_parse_sized (jv_parse.c:865)
==14129==    by 0x136BD9: run_jq_tests (jq_test.c:183)
==14129==    by 0x1370FA: jq_testsuite (jq_test.c:34)
==14129==    by 0x13135C: main (main.c:582)
==14129==
2023-07-24 11:16:22 -05:00
16ae275d4c Fix leaks on invalid input for strftime, strflocaltime and mktime 2023-07-24 16:45:43 +02:00
97c6d2848c Add fuzzer targeting load_file
Signed-off-by: David Korczynski <david@adalogics.com>
2023-07-24 15:45:12 +02:00
8a4f246876 Remove all #define _GNU_SOURCE in source files
This is unnecessary since we are using AC_USE_SYSTEM_EXTENSIONS in
configure.ac, which makes the compiler always run with -D_GNU_SOURCE=1
when building for GNU/Linux.

Also, the  #define _GNU_SOURCE  in src/util.c, and in
src/inject_errors.c (--enable-inject-errors), were not guarded by a
#ifndef _GNU_SOURCE  so they were just triggering redefinition warnings.
2023-07-24 15:44:29 +02:00