Created
October 29, 2024 08:01
-
-
Save janhicken/359f0a8d4c33ed192cebd3903e4b2667 to your computer and use it in GitHub Desktop.
URL decoding in pure Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o nounset | |
while read -r line; do | |
# Convert '+' to ' ' | |
with_spaces="${line//+/ }" | |
# Decode hex-encoded stuff using \x backslash escapes | |
printf '%b' "${with_spaces//%/\\x}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment