diff options
author | Simon McVittie <smcv@debian.org> | 2014-10-05 15:56:19 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2014-10-05 15:56:19 +0100 |
commit | 532f7adfdba3c852487216b0241b25d3de57acc6 (patch) | |
tree | a60cab10931514018069fbac24968a180b38d108 /t | |
parent | fe9e94513ab0d57f182a6922957ea14c773b4fae (diff) | |
download | ikiwiki-532f7adfdba3c852487216b0241b25d3de57acc6.tar ikiwiki-532f7adfdba3c852487216b0241b25d3de57acc6.tar.gz |
Use protocol-relative URIs if cgiurl and url differ only by authority (hostname)
Diffstat (limited to 't')
-rwxr-xr-x | t/relativity.t | 3 | ||||
-rwxr-xr-x | t/urlto.t | 15 |
2 files changed, 12 insertions, 6 deletions
diff --git a/t/relativity.t b/t/relativity.t index eb6cc448a..6c4d1107e 100755 --- a/t/relativity.t +++ b/t/relativity.t @@ -227,13 +227,10 @@ run(["./t/tmp/ikiwiki.cgi"], \undef, \$content, init => sub { $ENV{HTTPS} = 'on'; }); %bits = parse_cgi_content($content); -TODO: { -local $TODO = "avoid mixed content"; like($bits{basehref}, qr{^https://static.example.com/$}); like($bits{stylehref}, qr{^(?:(?:https:)?//static.example.com)?/style.css$}); like($bits{tophref}, qr{^(?:https:)?//static.example.com/$}); like($bits{cgihref}, qr{^(?:(?:https:)?//cgi.example.com)?/ikiwiki.cgi$}); -} # when accessed via a different hostname, links to the CGI (only) should # stay on that host? @@ -1,7 +1,7 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More tests => 26; +use Test::More tests => 31; BEGIN { use_ok("IkiWiki"); } @@ -41,11 +41,20 @@ is(IkiWiki::urlto('', 'penguin/herring'), "../../"); is(IkiWiki::cgiurl(cgiurl => 'https://foo/ikiwiki'), "https://foo/ikiwiki"); is(IkiWiki::cgiurl(do => 'badger', cgiurl => 'https://foo/ikiwiki'), "https://foo/ikiwiki?do=badger"); -# with url and cgiurl on different sites, "local" degrades to absolute +# with url and cgiurl on different sites, "local" degrades to protocol-relative $IkiWiki::config{url} = "http://example.co.uk/~smcv"; $IkiWiki::config{cgiurl} = "http://dynamic.example.co.uk/~smcv/ikiwiki.cgi"; is(IkiWiki::checkconfig(), 1); -is(IkiWiki::cgiurl(), "http://dynamic.example.co.uk/~smcv/ikiwiki.cgi"); +is(IkiWiki::cgiurl(), "//dynamic.example.co.uk/~smcv/ikiwiki.cgi"); +is(IkiWiki::baseurl(undef), "//example.co.uk/~smcv/"); +is(IkiWiki::urlto('stoats', undef), "//example.co.uk/~smcv/stoats/"); +is(IkiWiki::urlto('', undef), "//example.co.uk/~smcv/"); + +# with url and cgiurl on different schemes, "local" degrades to absolute +$IkiWiki::config{url} = "http://example.co.uk/~smcv"; +$IkiWiki::config{cgiurl} = "https://dynamic.example.co.uk/~smcv/ikiwiki.cgi"; +is(IkiWiki::checkconfig(), 1); +is(IkiWiki::cgiurl(), "https://dynamic.example.co.uk/~smcv/ikiwiki.cgi"); is(IkiWiki::baseurl(undef), "http://example.co.uk/~smcv/"); is(IkiWiki::urlto('stoats', undef), "http://example.co.uk/~smcv/stoats/"); is(IkiWiki::urlto('', undef), "http://example.co.uk/~smcv/"); |