diff options
author | dteske <dteske@FreeBSD.org> | 2013-06-23 09:41:47 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-06-23 09:41:47 +0000 |
commit | b9bf1edc0c801b2f4a08a6ca2b57453ab171c95b (patch) | |
tree | bf26267c7b170710c8315c1bcc70b2852ff6c2a3 /usr.sbin | |
parent | 456a58318f772df57faf95799c77f849e8e59e16 (diff) | |
download | FreeBSD-src-b9bf1edc0c801b2f4a08a6ca2b57453ab171c95b.zip FreeBSD-src-b9bf1edc0c801b2f4a08a6ca2b57453ab171c95b.tar.gz |
Fine-tune the parsing of the URL. Re-order, comment, and add debugging to
each case of unique URL format.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bsdconfig/share/media/ftp.subr | 57 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/share/media/httpproxy.subr | 26 |
2 files changed, 66 insertions, 17 deletions
diff --git a/usr.sbin/bsdconfig/share/media/ftp.subr b/usr.sbin/bsdconfig/share/media/ftp.subr index 6a7601d..c2c7e6a 100644 --- a/usr.sbin/bsdconfig/share/media/ftp.subr +++ b/usr.sbin/bsdconfig/share/media/ftp.subr @@ -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" diff --git a/usr.sbin/bsdconfig/share/media/httpproxy.subr b/usr.sbin/bsdconfig/share/media/httpproxy.subr index d2b2cfc..819d240 100644 --- a/usr.sbin/bsdconfig/share/media/httpproxy.subr +++ b/usr.sbin/bsdconfig/share/media/httpproxy.subr @@ -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" |