From a8d1fde715a6a1bd9a80e464f0da4c8548b67ec9 Mon Sep 17 00:00:00 2001 From: paul Date: Sat, 20 Dec 2014 01:34:45 +0000 Subject: [PATCH] move urlsave function to cgi "lib" svn path=/trunk/; revision=29 --- cgi.sh | 4 ++++ pages/videoview.sh | 20 +++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cgi.sh b/cgi.sh index 49e68b4..2c4d45d 100755 --- a/cgi.sh +++ b/cgi.sh @@ -52,3 +52,7 @@ cgi_refdata() { # Parse GET data from referer _REF["$key"]="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")" done } + +urlsave(){ + echo -E "$*" |sed 's:%:\%25:g;s:\?:\%3F:g;s:&:\%26:g;s:'\'':\%27:g;s: :\%20:g;s;!;\%21;g;s;\(;\%28;g;s;\);\%29;g;' +} diff --git a/pages/videoview.sh b/pages/videoview.sh index 738eeb1..e90c951 100755 --- a/pages/videoview.sh +++ b/pages/videoview.sh @@ -20,12 +20,12 @@ info="$_GET[\"i\"]" filter="$_GET[\"f\"]" search="$_GET[\"s\"]" -order=$(echo "$_GET[\"o\"]" |egrep '^(Name|Date|Length)$') -page=$(echo "$_GET[\"p\"]" |egrep '^[0-9]+$') +order=$(echo -E "$_GET[\"o\"]" |egrep '^(Name|Date|Length)$') +page=$(echo -E "$_GET[\"p\"]" |egrep '^[0-9]+$') [ -z "$page" ] && page=0 page_link='' -[ -n "$info" ] && page_link="i=$(echo -n "$info" |sed -r 's:%:%25:g;s:\&:%26:g;')&" +[ -n "$info" ] && page_link="i=$(echo -En "$info" |sed -r 's:%:%25:g;s:\&:%26:g;')&" [ -n "$order" ] && page_link="${page_link}o=${order}&" [ -n "$search" ] && page_link="${page_link}s=${search}&" [ -n "$filter" ] && page_link="${page_link}f=${filter}&" @@ -69,8 +69,6 @@ view() { fi } -alias urlsave="sed 's:%:\%25:g;s:\?:\%3F:g;s:&:\%26:g;s:'\'':\%27:g;s: :\%20:g;s;!;\%21;g;s;\(;\%28;g;s;\);\%29;g;'" - _printVideo(){ info="$1" cache="${_DATA}/cache/$info.cache" @@ -92,15 +90,15 @@ _printVideo(){ [ -r "$meta" ] || ". ${_EXEC}/helpers/genmeta.sh" "$video" "$meta" [ -r "$thumb" ] || ". ${_EXEC}/helpers/genthumb.sh" "$video" "$thumb" [ -L "$mpfake" ] || ln -s "../videos/$info" "$mpfake" - video="$(echo "videos/$info" |urlsave)" - thumb="$(echo "thumbs/$info.jpg" |urlsave)" - mpfake="$(echo "$info" |sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:mp4/\1.mp4:' |urlsave)" + video="$(urlsave "videos/$info")" + thumb="$(urlsave "thumbs/$info.jpg")" + mpfake="$(urlsave "$info" |sed -r 's:^(.*)\.[a-zA-Z0-9]{3,4}$:mp4/\1.mp4:')" [ "$(($length % 60))" -lt 10 ] &&\ minutes="$(($length / 60)):0$(($length % 60))" ||\ minutes="$(($length / 60)):$(($length % 60))" - linkinfo="$(echo -n "$info" |urlsave)" + linkinfo="$(urlsave "$info")" tee "$cache" < @@ -112,7 +110,7 @@ _printVideo(){ ${minutes}min ${width}x${height} - $(echo "$tags" |sed -r 's:\|*([^|]+)\|*:\1:g') + $(echo -E "$tags" |sed -r 's:\|*([^|]+)\|*:\1:g') VIDEOend fi @@ -151,7 +149,7 @@ thumblist() { $genlist |sed -rn 's:^(.+)$:'"${_DATA}"'/meta/\1'.meta':p' |xargs -d\\n egrep -sil "$search" |sed -rn 's:^(.*/)+([^/]+)\.meta$:\2:p' elif [ "$filterex" != "q0" ]; then $genlist |while read video; do - [ -r "${_DATA}/meta/$video.meta" ] && sed -rn "2{$filterex;q1}" "${_DATA}/meta/$video.meta" && echo "$video" + [ -r "${_DATA}/meta/$video.meta" ] && sed -rn "2{$filterex;q1}" "${_DATA}/meta/$video.meta" && echo -E "$video" done else $genlist -- 2.39.2