invidious: only allow "known" URLs

This commit is contained in:
Lucas 2020-05-02 20:43:38 +00:00
parent 0a7dd126e8
commit 7f89a0aaf8

View File

@ -28,6 +28,16 @@ api()
printf "https://%s%s\n" "$INVIDIOUS" "$*"
}
known_site()
{
printf "%s\n" "$1" | grep -Eq \
-e "^https://(www\.)?youtube\.com/" \
-e "^https://youtu\.be/" \
-e "^https://(www\.)?invidio\.us/" \
-e "^https://invidious\.snopyta\.org/" \
-e "^https://yewtu\.be/"
}
: ${INVIDIOUS:=invidious.snopyta.org}
torsocks=torsocks
@ -42,8 +52,8 @@ done
shift $((OPTIND - 1))
[ $# -eq 1 ] || usage
# XXX check URL for known sites
url=$1
known_site "$url" || err "Unknown site: $url"
oldIFS=$IFS
IFS="&"