-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@base64d doesn't match based64 -d output #1931
Comments
In brief,
This could be restated as follows:
Here Using the
|
Fair enough. I'd make the suggestion to document that the results of Having put this to rest, is there any plans to have a way to "shell out" to call external utilities to aid in processing this edge cases? |
@mterron - I believe the author or authors of this particular section of the official manual did not want to commit to any particular behavior at the time of writing, no doubt because, as you say, there is much to be said for raising an error condition. As for shelling out -- yes, there are plans to support this (see e.g. #147 and #1614), but it won't help much in the present case, for the reason already stated. |
@pkoppstein give a way to shell out I'll make it work :) Thanks! |
@mterron wrote:
It appears you are not quite grasping the fact that the implementation of the shell-out function will (of necessity) be designed to prevent what I understand you want to do. The "j" in jq can be understood as a commitment that, with two exceptions, every jq filter should produce strictly valid JSON, the exceptions being the values for This is not to say that every version of jq is guaranteed to reject non-JSON strings, but that's not for want of trying :-) |
Oh I understand very well. xxd will convert the binary back to an hexadecimal string that is valid json |
@mterron - Excellent. You might want to mention your use case on one of the shell-out tracking issues. |
I think this is worth fixing and it does not break compatibility. It is useful if we can decode the image data from |
Congratulations to @itchyny on gojq's @base64d, which passes the test using https://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html with flying colors. With B as a local copy of this file:
|
@pkoppstein does that mean that the Go version of Now I'd really love to see a benchmark comparing the two :) [note: I'm well aware that Just tested it on macOS. |
@GwynethLlewelyn - gojq is unquestionably better than jq in several important respects -- My experience has been that, in general, gojq tends to trade memory
There is also the matter of retaining the order of keys within |
As a user of jq I'm sorely disappointed that a simple note on the limitation of this function isn't in the manpage with over 5 years of lead time. I spent a good couple hours debugging why my base64 decoded strings were getting corrupted only to find that it's a known limitation of jq. There is a note in the manpage about how interpolation behaves and nothing else. |
@hachi - In the section on @base64d, the man page (https://jqlang.github.io/jq/manual/) says:
|
Describe the bug
The output of jq's @base64d does not match the output of
base64 -d
for the same stringTo Reproduce
Expected behavior
The outputs of
echo "V0MsL2hwbyCcGs2AMrFAKaSjPl8OuX4OWAEip+idGVU=" | jq -Rr '@base64d' | xxd -p -c64
andecho "V0MsL2hwbyCcGs2AMrFAKaSjPl8OuX4OWAEip+idGVU=" | base64 -d | xxd -p -c64
should be equal.Environment (please complete the following information):
Additional context
Seems to be related to binary values being encoded.
The text was updated successfully, but these errors were encountered: