Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.140.2.45 -r1.140.2.46 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 16 Aug 2016 18:27:10 -0000 1.140.2.45 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 30 Aug 2016 10:39:32 -0000 1.140.2.46 @@ -2566,6 +2566,7 @@ @author Gustaf Neumann @return boolean value indicating success + @see util::split_location } { upvar $protoVar proto $hostnameVar hostname $portVar port @@ -2591,6 +2592,28 @@ return $success } +ad_proc util::join_location {{-proto ""} {-hostname} {-port ""}} { + Join hostname and port and use IP-literal notation when necessary. + The function is the inverse function of util::split_location. + @return location consisting of hostname and optionally port + @author Gustaf Neumann + @see util::split_location +} { + set result "" + if {$proto ne ""} { + append result $proto:// + } + if {[string match *:* $hostname]} { + append result "\[$hostname\]" + } else { + append result $hostname + } + if {$port ne ""} { + append result :$port + } + return $result +} + ad_proc -public util_current_location {} { Like ad_conn location - Returns the location string of the current request in the form protocol://hostname[:port] but it looks at the @@ -2686,7 +2709,7 @@ } set ::__util_current_location $result - #ns_log notice "util_current_location returns <$result>" + #ns_log notice "util_current_location returns <$result> based on hostname <$hostname>" return $result } @@ -4634,14 +4657,19 @@ # be external. # if {$external_url_p} { + # + # If it has a protocol, we have to be able to find it in security::locations + # set locations_list [security::locations] # more valid url pairs with host_node_map foreach location $locations_list { - set encoded_location [ns_urlencode $location] - # ns_log Notice "util::external_url_p location \"$location/*\" url $url match [string match "${encoded_location}/*" $url]" - set external_url_p [expr { $external_url_p && ![string match "$location/*" $url] } ] - set external_url_p [expr { $external_url_p && ![string match "${encoded_location}/*" $url] } ] + set len [string length $location] + #ns_log notice "util::external_url_p location match <$location/*> with <$url> sub <[string range $url 0 $len-1]>" + if {[string range $url 0 $len-1] eq $location} { + set external_url_p 0 + break + } } } return $external_url_p