Skip to content
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

Escape all shell special characters #23

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jqjq.jq
Original file line number Diff line number Diff line change
Expand Up @@ -2735,9 +2735,9 @@ def parse_options:
);

def invoke_client_jqjq:
# instead of @sh to not always quote
# instead of @sh to not always quote (as per quoting rules of ${var@Q})
def sh_escape:
if . == "" or test("['\" $\n\\\\()]") then
if . == "" or test("[^[A-Za-z0-9%+\\-./:=@_]]") then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 yeap that feels safer. that stackoverflow response is quite impressive!

"'" + gsub("'"; "'\\''") + "'"
end;
( . as $args
Expand Down