aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2014-10-05 15:56:19 +0100
committerSimon McVittie <smcv@debian.org>2014-10-05 15:56:19 +0100
commit532f7adfdba3c852487216b0241b25d3de57acc6 (patch)
treea60cab10931514018069fbac24968a180b38d108 /t
parentfe9e94513ab0d57f182a6922957ea14c773b4fae (diff)
downloadikiwiki-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-xt/relativity.t3
-rwxr-xr-xt/urlto.t15
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?
diff --git a/t/urlto.t b/t/urlto.t
index 338632e94..025409b7f 100755
--- a/t/urlto.t
+++ b/t/urlto.t
@@ -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/");