svn commit: r252109 - head/usr.sbin/bsdconfig/share/media
Devin Teske
dteske at FreeBSD.org
Sun Jun 23 09:41:48 UTC 2013
Author: dteske
Date: Sun Jun 23 09:41:47 2013
New Revision: 252109
URL: http://svnweb.freebsd.org/changeset/base/252109
Log:
Fine-tune the parsing of the URL. Re-order, comment, and add debugging to
each case of unique URL format.
Modified:
head/usr.sbin/bsdconfig/share/media/ftp.subr
head/usr.sbin/bsdconfig/share/media/httpproxy.subr
Modified: head/usr.sbin/bsdconfig/share/media/ftp.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/media/ftp.subr Sun Jun 23 09:34:55 2013 (r252108)
+++ head/usr.sbin/bsdconfig/share/media/ftp.subr Sun Jun 23 09:41:47 2013 (r252109)
@@ -378,27 +378,62 @@ f_media_set_ftp()
local hostname="${url#*://}" port=21 dir=/
case "$hostname" in
- "["*"]")
+ #
+ # The order in-which the below individual cases appear is important!
+ #
+ "["*"]":*/*) # IPv6 address with port and directory
+ f_dprintf "Looks like an IPv6 addr with port/dir: %s" \
+ "$hostname"
hostname="${hostname#\[}"
- hostname="${hostname%%\]*}"
+ port="${hostname#*\]:}"
+ port="${port%%[!0-9]*}"
+ dir="/${hostname#*/}"
+ hostname="${hostname%%\]:*}"
;;
- "["*"]/"*)
+ "["*"]":*) # IPv6 address with port
+ f_dprintf "Looks like an IPv6 addr with port: %s" "$hostname"
hostname="${hostname#\[}"
- dir="/${hostname#*/}"
- hostname="${hostname%%\]*}"
+ port="${hostname#*\]:}"
+ port="${port%%[!0-9]*}"
+ hostname="${hostname%%\]:*}"
;;
- *"/"*)
+ "["*"]"/*) # IPv6 address with directory
+ f_dprintf "Looks like an IPv6 addr with dir: %s" "$hostname"
+ hostname="${hostname#\[}"
dir="/${hostname#*/}"
- hostname="${hostname%%/*}"
+ hostname="${hostname%%\]*}"
;;
- "["*"]:"*)
+ "["*"]") # IPv6 address
+ f_dprintf "Looks like an IPv6 addr: %s" "$hostname"
hostname="${hostname#\[}"
- port="${hostname#*\]:}"
+ hostname="${hostname%\]}"
+ ;;
+ #
+ # ^^^ IPv6 above / DNS Name or IPv4 below vvv
+ #
+ *:*/*) # DNS name or IPv4 address with port and directory
+ f_dprintf "Looks like a %s with port/dir: %s" \
+ "DNS name or IPv4 addr" "$hostname"
+ port="${hostname#*:}"
port="${port%%[!0-9]*}"
- hostname="${hostname%%\]:*}"
+ dir="/${hostname#*/}"
+ hostname="${hostname%%:*}"
+ ;;
+ *:*) # DNS name or IPv4 address with port
+ f_dprintf "Looks like a DNS name or IPv4 addr with port: %s" \
+ "$hostname"
+ port="${hostname#*:}"
+ hostname="${hostname%%:*}"
;;
- *)
+ */*) # DNS name or IPv4 address with directory
+ f_dprintf "Looks like a DNS name or IPv4 addr with dir: %s" \
+ "$hostname"
+ dir="/${hostname#*/}"
hostname="${hostname%%/*}"
+ ;;
+ *) # DNS name or IPv4 address
+ f_dprintf "Looks like a DNS name or IPv4 addr: %s" "$hostname"
+ : leave hostname as-is
esac
f_dprintf "hostname = \`%s'" "$hostname"
Modified: head/usr.sbin/bsdconfig/share/media/httpproxy.subr
==============================================================================
--- head/usr.sbin/bsdconfig/share/media/httpproxy.subr Sun Jun 23 09:34:55 2013 (r252108)
+++ head/usr.sbin/bsdconfig/share/media/httpproxy.subr Sun Jun 23 09:41:47 2013 (r252109)
@@ -77,19 +77,33 @@ f_media_set_http_proxy()
local hostname="$proxy" port=3128
case "$hostname" in
- "["*"]")
- hostname="${hostname#\[}"
- hostname="${hostname%\]}"
- ;;
- "["*"]:"*)
+ #
+ # The order in-which the below individual cases appear is important!
+ #
+ "["*"]":*) # IPv6 address with port
+ f_dprintf "Looks like an IPv6 addr with port: %s" "$hostname"
hostname="${hostname#\[}"
port="${hostname#*\]:}"
port="${port%%[!0-9]*}"
hostname="${hostname%%\]:*}"
;;
- *":"*)
+ "["*"]") # IPv6 address
+ f_dprintf "Looks like an IPv6 addr: %s" "$hostname"
+ hostname="${hostname#\[}"
+ hostname="${hostname%\]}"
+ ;;
+ #
+ # ^^^ IPv6 above / DNS Name or IPv4 below vvv
+ #
+ *:*) # DNS name or IPv4 address with port
+ f_dprintf "Looks like a DNS name or IPv4 addr with port: %s" \
+ "$hostname"
port="${hostname#*:}"
hostname="${hostname%%:*}"
+ ;;
+ *) # DNS name or IPv4 address
+ f_dprintf "Looks like a DNS name or IPv4 addr: %s" "$hostname"
+ : leave hostname as-is
esac
setvar $VAR_HTTP_PROXY_HOST "$hostname"
More information about the svn-src-head
mailing list