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.
This commit is contained in:
itchyny authored and Nico Williams committed 2023-07-26 23:55:00 -05:00
1 parent 13fbe98dff
commit a1e791acf8
4 files changed
+41 -30

No files matched your search

Generated
+6 -6
View File
@@ -82,18 +82,18 @@ By default, jq pretty\-prints JSON output\. Using this option will result in mor
With this option, if the filter\'s result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes\. This can be useful for making jq filters talk to non\-JSON\-based systems\.
.
.TP
\fB\-\-raw\-output0\fR:
.
.IP
Like \fB\-r\fR but jq will print NUL instead of newline after each output\. This can be useful when the values being output can contain newlines\. When the output value contains NUL, jq exits with non\-zero code\.
.
.TP
\fB\-\-join\-output\fR / \fB\-j\fR:
.
.IP
Like \fB\-r\fR but jq won\'t print a newline after each output\.
.
.TP
\fB\-\-nul\-output\fR / \fB\-0\fR:
.
.IP
Like \fB\-r\fR but jq will print NUL instead of newline after each output\. This can be useful when the values being output can contain newlines\.
.
.TP
\fB\-\-ascii\-output\fR / \fB\-a\fR:
.
.IP