Overview
| Artifact ID: | d1d04642f017bd92a668bcdd34337f2de99885ff |
|---|---|
| Ticket: | 3531209fffffffffffffffffffffffffffffffff
Improper support for IPv6 raw address in http library |
| User & Date: | efrecon on 2012-05-31 22:28:35 |
Changes
- assignee changed to: "patthoyts"
- cmimetype changed to: "text/plain"
- comment changed to:
The current implementation of the http library does not support URLs that contain raw IPv6 specifications, i.e. http://[2001:5c0:1400:b::d623]/ to take mine as an example. The problem is that the atom of the regexp that should match the host part of the authority is written as [^/:\#?]+ which will not work since IPv6 addresses are written using : as separators (well, not *entirely* true, but almost). Therefore, the parsing stops at improper places within the URL specification and ends up not being able to open the socket against the IP address, even though Tcl 8.6 now has support for IPv6. The following code (extract out of the "parsing" part of the geturl procedure actually performs the work properly: set URLmatcher {(?x) # this is _expanded_ syntax ^ (?: (\w+) : ) ? # <protocol scheme> (?: // ( [^/\#?]+ ) # <location=userinfo + host + port> )? ( / [^\#]*)? # <path> (including query) (?: \# (.*) )? # <fragment> $ } # Phase one: parse, the URL match if {![regexp -- $URLmatcher $url -> proto location srvurl]} { unset $token return -code error "Unsupported URL: $url" } if { [string first "@" $location] >= 0 } { foreach {user hostport} [split $location "@"] break } else { set user "" set hostport $location } set idx [string last ":" $hostport] if { $idx >= 0 } { set port [string trimleft [string range $hostport $idx end] ":"] if { [string is integer $port] } { set host [string trimright [string range $hostport 0 $idx] ":"] } else { set port "" set host $hostport } } else { set port "" set host $hostport } set host [string trim $host "\[\]"] # Phase two: validate This version minimises the regexp parsing and adds a number of string operations. It's not perfect, but at least solve the issue. A regexp guru would be needed to fix this at the regexp level. - foundin changed to: "None"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "efrecon"
- subsystem changed to: "29. http Package"
- title changed to:
Improper support for IPv6 raw address in http library
- type changed to: "Bug"