summaryrefslogtreecommitdiff
path: root/urititle
diff options
context:
space:
mode:
authorepoch <epoch@hack.thebackupbox.net>2020-10-18 03:57:52 +0000
committerepoch <epoch@hack.thebackupbox.net>2020-10-18 03:57:52 +0000
commitd88e13ca253bd1f2c3acad0dae911f7aa0669dec (patch)
tree31b8db7a881f554df0ba5c9e48eefb98a3c5b5e3 /urititle
parent9705a81be3e6a7d63909074ab45b862b46c6d88f (diff)
downloaduritools-d88e13ca253bd1f2c3acad0dae911f7aa0669dec.tar.gz
uritools-d88e13ca253bd1f2c3acad0dae911f7aa0669dec.zip
urititle can now do ftp URIs and if curl errors out on http or https URIs, it'll let you know.
Diffstat (limited to 'urititle')
-rwxr-xr-xurititle17
1 files changed, 12 insertions, 5 deletions
diff --git a/urititle b/urititle
index f6f93ea..6367473 100755
--- a/urititle
+++ b/urititle
@@ -18,21 +18,25 @@ if [ "$qs" ];then
fi
case "$scheme" in
http*)
-if [ "$port" ];then
+ if [ "$port" ];then
UA="Mozilla/5.0 (impersonator)"
# content_type="$(printf "HEAD %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n" "$path" "$domain" "$UA" | ncat -4 $SSL "$domain" "$port" | grep -i '^Content-Type: ' | head -n1 | cut '-d ' -f2 | cut '-d;' -f1 | tr -d '\r\n')"
- a_header="$(curl -Lsi "$1" | head -c 10000 | egrep -ai '^Location: |^Content-Type: ' | head -n1 | tr -d '\r\n')"
+ a_header="$((curl -Lsi "$1" || echo curl failed) | head -c 10000 | egrep -ai '^curl failed|^Location: |^Content-Type: ' | head -n1 | tr -d '\r\n')"
if printf "%s\n" "${a_header}" | grep -i '^Content-Type: ' 2>&1 >/dev/null 2>&1;then
content_type="$(printf '%s\n' "${a_header}" | cut '-d ' -f2- | cut '-d;' -f1)"
- else
- content_type="redirect probably"
+ fi
+ if printf "%s\n" "${a_header}" | grep -i '^Location: ' 2>&1 >/dev/null 2>&1;then
+ content_type="redirect. ${a_header}"
+ fi
+ if printf "%s\n" "${a_hreader}" | grep -i '^curl failed' 2>&1 >/dev/null 2>&1;then
+ content_type="curl failed. cert expired? dunno yet. TODO: code openssl checker."
fi
if [ "${content_type}" = "text/html" -o "${content_type}" = "application/xhtml+xml" ];then
# title="$(printf "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n" "$path" "$domain" "$UA" | ncat -4 $SSL "$domain" "$port" | head -c 10000 | tr -d '\n' | tr '<' '\n' | grep -A 10 '^title>' | grep -B 10 '^\/title>' | cut '-d>' -f2)"
title="$(curl -si "$1" | head -c 1000000 | tr -d '\n' | tr '<' '\n' | grep -iA 10 '^title' | grep -iB 10 '^\/title>' | cut '-d>' -f2 | tr '\t' ' ' | sed 's/^ *//g' | sed 's/ *$//g' | grep .)"
printf "title: %s\n" "$title" | html_entities_decode
else
- printf "%s\n" "${a_header}"
+ printf "%s %s\n" "${a_header}" "${content_type}"
fi
fi
;;
@@ -52,6 +56,9 @@ gemini)
magnet)
printf "title: %s\n" "$(printf "%s\n" "$1" | tr '&' '\n' | grep ^dn= | cut -d= -f2- | uriunescape)"
;;
+ftp)
+ curl "$1" 2>&1 | tail -n1
+ ;;
ssh)
if [ ! "$port" ];then
port=22