Skip to content

Commit 21d4a54

Browse files
author
Nhoya
committed
Added URL encoding for get request soling 90% of Error 406
1 parent 97f320e commit 21d4a54

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

z0r

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ readonly YELLOW="\033[00;33m"
2222
readonly BOLD="\033[01m"
2323
readonly FINE="\033[0m"
2424

25-
ver='v1.7.1'
25+
ver='v1.7.2'
2626
regex='(https?|ftp|file)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*\.[A-Za-z0-9\+&@%#/=~_|():?]+'
2727
is_z0r='http://z0r.it/[^ \n]'
2828
url=(http://$1)
@@ -31,13 +31,14 @@ dep=(curl awk xclip wget)
3131
apikey=4e4b657a91
3232
clip=$(xclip -o 2>/dev/null)
3333
LOGDIR=/$HOME/.z0r_logs
34+
url_e=$(echo "$1"| sed 's/?/%3F/')
3435
#upload function (long -> short)
3536
shr(){
36-
short=$(curl $mode -L "http://z0r.it/yourls-api.php?signature=$apikey&action=shorturl&title=uploaded_with_z0r_script&keyword=$2&format=simply&url=$1"|awk -F '/' '{print$NF}')
37+
short=$(curl $mode -L "http://z0r.it/yourls-api.php?signature=$apikey&action=shorturl&title=uploaded_with_z0r_script&keyword=$2&format=simply&url=$url_e"|awk -F '/' '{print$NF}')
3738
uc="http://z0r.it/$short"
3839
if [ -n "$short" ]; then
39-
if curl $mode -L "http://z0r.it/yourls-api.php?signature=$apikey&action=shorturl&title=uploaded_with_z0r_script&keyword=$2&format=simply&url=$1" |grep -q "Errore 406"; then
40-
echo -e $RED"Error 406 - URL not valid(try to use https instead of http)"$FINE
40+
if curl $mode -L "http://z0r.it/yourls-api.php?signature=$apikey&action=shorturl&title=uploaded_with_z0r_script&keyword=$2&format=simply&url=$url_e" |grep -q "Errore 406"; then
41+
echo -e $RED"Error 406 - URL not valid(try to use https instead of http or try encoding the URL)"$FINE
4142
else
4243
echo "http://z0r.it/$short" && echo "$(date +"%d-%h-%Y %H.%M.%S") - $uc - $1">>$LOGDIR
4344
echo "$uc" |xclip -selection clipboard
@@ -84,10 +85,10 @@ stats(){
8485
}
8586
mss(){
8687
for i in ${@:2}; do
87-
mass=$(curl -s -L "http://z0r.it/yourls-api.php?signature=$apikey&action=shorturl&title=uploaded_with_z0r_script&format=simply&url=$i"|awk -F '/' '{print$NF}')
88+
mass=$(curl -s -L "http://z0r.it/yourls-api.php?signature=$apikey&action=shorturl&title=uploaded_with_z0r_script&format=simply&url=$(echo $i| sed 's/?/%3F/')"|awk -F '/' '{print$NF}')
8889
if wget --spider "$i" 2>/dev/null; then
8990
if [ -n "$mass" ] ; then
90-
if curl $mode -L "http://z0r.it/yourls-api.php?signature=$apikey&action=shorturl&title=uploaded_with_z0r_script&format=simply&url=$i" |grep -q "Errore 406"; then
91+
if curl $mode -L "http://z0r.it/yourls-api.php?signature=$apikey&action=shorturl&title=uploaded_with_z0r_script&format=simply&url=$(echo $i| sed 's/?/%3F/')" |grep -q "Errore 406"; then
9192
echo -e $RED"Error 406 - URL not valid(try to use https instead of http)"$FINE
9293
else
9394

0 commit comments

Comments
 (0)