Commit Graph
1696 Commits
Author SHA1 Message Date
wellweek c95b34ff82 remove repetitive words
Signed-off-by: wellweek <xiezitai@outlook.com>
2024-03-08 10:43:29 +01:00
itchyny ce0e788ce2 improve tonumber/0 performance by parsing input as number literal
Previously, the tonumber/0 filter parses the input as JSON values, but
this is less-performant on large non-number strings. Parsing the input
string as number literal fixes the performance issue. Also, this fix
changes the filter to reject numbers with white spaces.
2024-03-01 16:33:17 +01:00
Bhargava Mummadireddy 913b26469f docs: Update chocolatey install command in default.yml (#3042) 2024-02-13 16:50:58 +01:00
Emanuele Torre fc9ecd71b3 tests: run tests in C locale
Fixes #3038
2024-02-10 18:23:50 +01:00
Ulrich Eckhardt 623d7a8bd6 src/jv_dtoa.c: Fix compiler error 2024-02-08 19:27:48 +01:00
Ulrich Eckhardt 6980cc9713 src/builtin.c: Add missing semicolon 2024-02-08 19:27:48 +01:00
J. B. RainsbergerandEmanuele Torre 92d35378ff Fix typo in documentation for map_values (#3035)
* Fix typo in documentation for map_values

"map_value(f)" -> "map_values(f)"

* map_value => map_values also in the devolpment manual

---------

Co-authored-by: Emanuele Torre <torreemanuele6@gmail.com>
2024-02-08 13:52:50 +00:00
Thalia Archibald 54cc15c127 Add missing string color case
Colors have a color separate from object keys, so were not tested.
2024-02-08 00:11:54 -06:00
Thalia Archibald 48df9bce0c Clear formatting immediately after colon 2024-02-08 00:11:54 -06:00
Thalia Archibald 76853f6046 Fix tests and test indented printing 2024-02-08 00:11:54 -06:00
Thalia Archibald 3c37522aaa Consistently reset color formatting in jv_dump_term
Before, arrays would not reset colors after `[` and `,`, but objects
would; it would reset colors twice before `]` and `}`; and some cases of
indentation would have colors applied. Now, colors are reset immediately
after any token that is colored, before any indentation. This makes the
formatting consistent, for the benefit of custom `JQ_COLORS`.
2024-02-08 00:11:54 -06:00
Tomas Halman 8a9a74dc12 License: Improve license statement.
The README mentions only the MIT license but in fact part of `jq`
is under ICU license and the documentation is under CC.

Also jq.spec claimed that it is licensed under BSD.
2024-02-06 14:51:46 +01:00
Emanuele Torre 13e02ba348 docs: rename example jq utility to total
Apparently sum(1) is a BSD and GNU coreutil used to compute the
"16-bit BSD checksum" of a file.
2024-01-30 12:23:33 -06:00
Emanuele Torre bd3c828f98 libm.h+builtin.c: add and use LIBM_DA and LIBM_DA_NO macros
For functions that from one double return an array with two numbers.
2024-01-26 16:16:25 -06:00
Emanuele Torre 605836b263 builtin.c: fix build with -Woverlength-strings
C99 only allows string literals long at most 4095 characters.
jq_builtins was a lot longer than that.

I rewrote all the optional libm error stubs in C so the value of
jq_builtins is not build dependent.

I replaced the command that generates builtin.inc with a POSIX compliant
od|sed command that encodes builtin.jq as a comma delimited list of
octal numbers (that can be embedded in C using a {} literal).

I also added -Woverlength-strings to AM_CFLAGS to verify that the
problem is fixed.

Fixes #1481
2024-01-26 16:16:25 -06:00
Emanuele Torre 7bdc9a7a63 Makefile.am: fix lines indented with tabs instead of spaces 2024-01-26 16:13:35 -06:00
Jonathan Chan Kwan Yin 1daabc67ed typo contruct->construct (#3017) 2024-01-25 22:21:41 +01:00
Mattias Wadman c95f6ce700 Fix "in the a search" typo (#3015)
Fixes #3014
2024-01-24 23:34:41 +01:00
Emanuele Torre 1f1e619f4e builtins: make ltrimstr and rtrimstr error for non-string inputs
Previously, ltrimstr/rtrimstr would just let the input pass through for
non-string inputs or arguments.

That was happening because, they were leaking the errors returned by
startswith/endswith treating them as if they were jv_false().
The leak was resolved by #2977 for 1.7.1

This patch rewrites ltrimstr and rtrimstr in jq, and makes them not
ignore startswith and endswith errors anymore.
2024-01-16 16:57:37 -06:00
Emanuele Torre 71e7bcdfc1 Revert "lexer: temporarily revert #\ patch; keep CR in comment bug fix"
This reverts commit 5d95791a67.
2024-01-16 16:08:03 -06:00
George Hopkins f954e82b14 Provide strptime implementation on all systems 2024-01-16 16:01:27 -06:00
dependabot[bot] f51e841fbc Bump jinja2 from 3.1.2 to 3.1.3 in /docs (#3009)
Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-13 11:24:16 +09:00
dependabot[bot]anditchyny 2381d15d3e Bump the official-actions group with 2 updates (#2998)
* Bump the official-actions group with 2 updates

Bumps the official-actions group with 2 updates: [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/upload-artifact` from 3 to 4
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

Updates `actions/download-artifact` from 3 to 4
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: official-actions
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: official-actions
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix CI workflow for updating artifact actions to v4

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: itchyny <itchyny@cybozu.co.jp>
2024-01-09 09:33:26 +09:00
Mattias Wadman 701c880805 Add jq 1.7.1 news item (#3004) 2023-12-26 15:22:39 +09:00
wllm-rbnt 0b922725b1 Fix typo (#3002) 2023-12-24 11:22:20 +01:00
Mattias Wadman e011f003b6 Add jq 1.7.1 to webpage (#3003)
Make it the default download
2023-12-24 11:17:21 +01:00
itchyny 56828b6d04 Always build Docker image on CI, group Dependabot PRs for official actions (#2997)
* Always build docker image on CI

* Revert "Bump actions/download-artifact from 3 to 4"

This reverts commit 9e2695e117.

* Group Dependabot PRs for official actions
2023-12-19 17:54:53 +09:00
dependabot[bot] 9e2695e117 Bump actions/download-artifact from 3 to 4
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-18 15:18:47 +01:00
github-actions[bot]andgithub-actions[bot] 95c50a2d0d Update signatures of 1.7.1
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 20:52:03 +01:00
Emanuele Torre 71c2ab509a Merge pull request from GHSA-686w-5m7m-54vc
decNumberToString calls for a buffer that can hold a string of digits+14
characters, not a buffer of size digits+14.
We need to allocate an extra byte for the NUL byte.

-10E-1000010001, for example, will be stringified as -1.0E-1000010000
and decNumberToString will currently write an extra NUL byte after the
allocated buffer in the heap.

Originally reported by @SEU-SSL on GitHub.

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

Fixes GHSA-686w-5m7m-54vc
jq-1.7.1
2023-12-13 20:20:22 +01:00
Emanuele Torre c9a5156521 Merge pull request from GHSA-7hmr-442f-qc8j
The unit allocated for decNumberCompare was accidentally removed by
commit 680baeffeb (PR #2804)

This caused a stack overflow when comparing a nan with a payload of 1000
or more.

This bug was found by OSS-fuzz.
Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64771
Fixes GHSA-7hmr-442f-qc8j

It also fixes 1e999999999 > 1e-1147483646   triggering UBSAN errors
Fixes #2968
2023-12-13 20:17:17 +01:00
Emanuele Torre c5fd64ba97 jv_parse: let decNumberFromString/strtod parse complex nans as a NaN
Before this patch (when using decNumber), "Nan123" was parsed as a NaN,
only if the first n was uppercase.
2023-12-13 20:14:31 +01:00
Emanuele Torre dcf9a8e580 NEWS.md: fix markdown syntax; mention more bug fixs; list cves (#2987) 2023-12-13 18:39:24 +01:00
Mattias Wadman c3b14967d3 Update NEWS.md with changes since 1.7 (#2948) 2023-12-13 15:38:59 +00:00
Emanuele Torre 5d95791a67 lexer: temporarily revert #\ patch; keep CR in comment bug fix
This commit temporarily reverts the commit that allows #\ "tcl-style"
comments everywhere and documents them, for the 1.7.1 patch release
cca1f7d18f.

\r is removed from the list of characters not allowed in a comment to
preserve that bugfix.
2023-12-13 16:38:18 +01:00
Emanuele Torre 511d50b15b ltrimstr/1+rtrimstr/1: don't leak on invalid input or arguments
ltrimstr/rtrimstr was ignoring and leaking the error returned by
f_startswith()/f_endswith().

This also means that they just let the input pass through for non-string
inputs or arguments.

Only fix the leak for now; in the next release, #2969 will make them
rethrow the error returned by startswith/endswith.

Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64946
2023-12-13 15:13:46 +01:00
Emanuele Torre 7298972551 Makefile.am: don't use -lshlwapi to build jq on WIN32
It does not need it, only libjq needs this.
2023-12-13 13:08:57 +01:00
Emanuele Torre 19453a60cf ci.yml: use sysctl -n hw.logicalcpu instead of nproc on macos
The "macos (arm64)" runner on github does not have nproc.

/Users/runner/work/_temp/f44f0d9f-19eb-4a23-860e-26533d7efdfa.sh: line 10: nproc: command not found
2023-12-11 22:02:42 +01:00
Emanuele Torre 527c5abab1 jv_mem_calloc(): always call with (nmemb, size)
It does not matter much since they most likely just get multiplied
together, but some compilers would complain about this if these were
calls to calloc.
2023-12-11 20:47:32 +01:00
Emanuele Torre c2db51eeb3 shtest+configure: remove uses of non-portable/non-standard commands
Replace deprecated test(1) parentheses and -a logical operator with two
tests command.

Replace deprecated  tail -1  with  tail -n1.

Replace non-standard egrep(1) command with  grep -E  ; this also
prevents obsolescence warnings on GNU systems.
2023-12-11 20:46:54 +01:00
Emanuele Torre 507eb8283c shtest: fix out-of-source tests
The locale test was using ./jq intead of $JQ.

I also removed the use of obsolete egrep instead of grep -E that
triggers warnings on GNU systems, and the use of deprecated head -1
instead of head -n1.

Also removed the unnecessary hiding of strptime/1 errors with
? // false.
2023-12-11 20:45:14 +01:00
Jesper Rønn-Jensen 2ccab044fe chore: Improve readability (for Alternative operator '//')
The description of the Alternative operator `//` was hard for me to grasp in its wording.

I suggest dividing the looong sentence into two parts. Since it is actually an alternative formulation, the sentence can be divided into the first formulation, and the alternative formulation.
2023-12-11 11:38:54 +00:00
Emanuele Torre 7e54d9646e jq.test: fix setpath PR number
It was #2970, not 2967.
2023-12-11 09:58:09 +01:00
dependabot[bot] 22f81401f8 Bump actions/setup-python from 4 to 5
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-11 07:54:23 +01:00
Emanuele Torre 6b69ffe769 jv_setpath()+setpath/2: don't leak the input after an invalid get
Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64906
2023-12-10 19:40:29 +01:00
Emanuele Torre 80bc768c5d jq_fuzz_fixed: fix test cases that use string interpolation
"\(" is implementation-defined in C++, and both clang and gcc treat it
as equivalent to "(", not "\\(".
This patch replaces "\(" with "\\(" so that tests with string
interpolation actually use string interpolation.
2023-12-10 15:22:03 +01:00
David Korczynski 5029328d35 tests: add new fuzzer
Signed-off-by: David Korczynski <david@adalogics.com>
2023-12-07 12:57:54 +01:00
DavidKorczynski 20a403e97e jq_fuzz_execute.cpp: fix false assert
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64632 by following the suggestion here: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64632#c2 -- the issue is fixed when this attribute is set.

I did not add any of the other suggestions in the comment: we haven't run into these issues in the fuzzer so far.
2023-12-03 17:54:25 +01:00
DavidKorczynski 693a7261e5 jq_fuzz_execute: fix memory leak
Signed-off-by: David Korczynski <david@adalogics.com>
2023-12-03 03:53:49 +01:00
David Korczynski bfb7fd570f jq_fuzz_execute: cleanup un-needed extern
Signed-off-by: David Korczynski <david@adalogics.com>
2023-11-30 14:40:36 +01:00