From owner-svn-src-head@FreeBSD.ORG Sun Jun 23 09:41:48 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 385CD5B8; Sun, 23 Jun 2013 09:41:48 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 29C2616B3; Sun, 23 Jun 2013 09:41:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5N9fmUi085018; Sun, 23 Jun 2013 09:41:48 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5N9flsQ085016; Sun, 23 Jun 2013 09:41:47 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201306230941.r5N9flsQ085016@svn.freebsd.org> From: Devin Teske Date: Sun, 23 Jun 2013 09:41:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r252109 - head/usr.sbin/bsdconfig/share/media X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jun 2013 09:41:48 -0000 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"