mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-12 00:11:31 +00:00
~脚本进行大量拆分和优化
This commit is contained in:
15
scripts/libs/urlencode.sh
Normal file
15
scripts/libs/urlencode.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
urlencode() {
|
||||
LC_ALL=C
|
||||
printf '%s' "$1" \
|
||||
| hexdump -v -e '/1 "%02X\n"' \
|
||||
| while read -r hex; do
|
||||
case "$hex" in
|
||||
2D|2E|5F|7E|3[0-9]|4[1-9A-F]|5[0-9A]|6[1-9A-F]|7[0-9A-E])
|
||||
printf "\\$(printf '%03o' "0x$hex")"
|
||||
;;
|
||||
*)
|
||||
printf "%%%s" "$hex"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
Reference in New Issue
Block a user