Index: openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl,v diff -u -r1.79.2.70 -r1.79.2.71 --- openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 5 Jul 2024 13:43:29 -0000 1.79.2.70 +++ openacs-4/packages/acs-automated-testing/tcl/aa-test-procs.tcl 8 Jul 2024 14:10:34 -0000 1.79.2.71 @@ -1411,10 +1411,7 @@ # the location header may return a relative URL as # well. # - set location [util::complete_location \ - -location $location \ - -complete_url $test_url] - + ns_absoluteurl $location $test_url } } finally { # Index: openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl,v diff -u -r1.30.2.31 -r1.30.2.32 --- openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl 8 Jul 2024 13:20:05 -0000 1.30.2.31 +++ openacs-4/packages/acs-tcl/tcl/http-client-procs.tcl 8 Jul 2024 14:10:32 -0000 1.30.2.32 @@ -1133,9 +1133,7 @@ # https://www.rfc-editor.org/rfc/rfc7231#section-7.1.2, the # location header may return a relative URL as well. # - set location [util::absolute_url \ - -url $location \ - -base_url $url] + set location [ns_absoluteurl $location $url] if {$method eq "GET"} { return [$this_proc \ 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.189.2.177 -r1.189.2.178 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 8 Jul 2024 13:20:06 -0000 1.189.2.177 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 8 Jul 2024 14:10:32 -0000 1.189.2.178 @@ -1964,51 +1964,6 @@ return $result } -ad_proc util::absolute_url { - -url:required - -base_url -} { - - Value added version of "ns_absoluteurl" with the following differences - - - keep protocol relative URLs unchanged (no scheme is completed) - - use [util_current_location] as default "base_url" - - allow variable "url" to be empty (replaced by /) - - Completes specified URL when necessary. When no base URL is - specified, it will default to the current location (scheme and host). - - The purpose of this utility is to be used by HTTP clients to - complete URLs coming from the Location response header in case of - a redirect, which according to RFC 7231 may also be relative. - - @param url a supposedly relative URL to complete. When the - URL is already complete, it will be returned - as-is. - @param base_url URL of the redirected request. A complete URL - from which we want to read the host. When - missing, the URL will be completed using the - result of util_current_location. - - @return a complete absolute URL - - @see https://www.rfc-editor.org/rfc/rfc7231#section-7.1.2 - @see https://naviserver.sourceforge.io/n/naviserver/files/ns_absoluteurl.html -} { - if {![info exists base_url]} { - set base_url [util_current_location] - } - if {[dict exists [ns_parseurl -strict $url] host]} { - return $url - } - if {$url eq ""} { - set url / - } - #ns_log notice "================ XXX [list ns_absoluteurl $url $base_url] -> <[ns_absoluteurl $url $base_url]>" - return [ns_absoluteurl $url $base_url] -} - - ad_proc -public util::configured_location {{-suppress_port:boolean}} { Return the configured location as configured for the current Index: openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl,v diff -u -r1.1.2.22 -r1.1.2.23 --- openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 8 Jul 2024 13:20:09 -0000 1.1.2.22 +++ openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 8 Jul 2024 14:10:34 -0000 1.1.2.23 @@ -440,110 +440,6 @@ api production_safe } -procs { - util::absolute_url -} util__absolute_url { - Test util::absolute_url -} { - aa_equals "Basic case" \ - [string trimright [util::absolute_url -url ""] /] \ - [util_current_location] - - aa_equals "Complete URL with current location" \ - [string trimright [util::absolute_url -url "/a/b/c"] /] \ - [util_current_location]/a/b/c \ - - aa_equals "Complete an already complete URL (normie case)" \ - [util::absolute_url -url "https://example.com/a/b/c"] \ - "https://example.com/a/b/c" \ - - aa_equals "Complete an already complete URL (protocol relative)" \ - [util::absolute_url -url "//host.org/b/c"] \ - //host.org/b/c \ - - aa_true "Complete an invalid URL (relative) - Should fail" \ - [catch { - util::absolute_url -url "/file\[/\].html" - }] - - aa_true "Complete an invalid URL (absolute) - Should fail" \ - [catch { - util::absolute_url -url "http://example.com/file\[/\].html" - }] - - aa_equals "Basic case with external base URL" \ - [string trimright [util::absolute_url \ - -url "" \ - -base_url "http://example.com"] \ - /] \ - http://example.com - - aa_equals "Basic case with external base URL (complete_url has a path)" \ - [string trimright [util::absolute_url \ - -url "" \ - -base_url "http://example.com/a/b/c"] \ - /] \ - http://example.com - - aa_equals "Complete with external base URL (complete_url just the host)" \ - [string trimright [util::absolute_url \ - -url "/a/b/c" \ - -base_url "http://example.com"] \ - /] \ - http://example.com/a/b/c - - aa_equals "Complete with external base URL (complete_url with a path)" \ - [string trimright [util::absolute_url \ - -url "/a/b/c" \ - -base_url "http://example.com/d/e/f"] \ - /] \ - http://example.com/a/b/c - - aa_equals "Complete an already complete URL (normie case)" \ - [util::absolute_url \ - -url "https://example.com/a/b/c" \ - -base_url "http://anotherexample.com/d/e/f"] \ - https://example.com/a/b/c - - aa_equals "Complete an already complete URL (protocol relative)" \ - [util::absolute_url \ - -url "//host.org/b/c" \ - -base_url "http://anotherexample.com/d/e/f"] \ - //host.org/b/c - - aa_true "Complete an invalid URL (relative) - Should fail" \ - [catch { - util::absolute_url \ - -url "/file\[/\].html" \ - -base_url "http://example.com/d/e/f" - }] - - aa_true "Complete an invalid URL (absolute) - Should fail" \ - [catch { - util::absolute_url \ - -url "http://example.com/file\[/\].html" \ - -base_url "http://example.com/d/e/f" - }] - - aa_true "Complete with an invalid base URL - Should fail" \ - [catch { - util::absolute_url \ - -url "/file/a/b" \ - -base_url "://example.com/file.html" - }] - - aa_true "Complete with a relative base URL - Should fail" \ - [catch { - util::absolute_url \ - -url "/file/a/b" \ - -base_url "/c/d/e" - }] -} - - -aa_register_case -cats { - api - production_safe -} -procs { util::file_content_check } util__file_content_check { Test util::file_content_check.