aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2014-11-26 11:58:05 +0000
committerSimon McVittie <smcv@debian.org>2014-11-26 11:58:05 +0000
commit6c51b764bca2981b8962d7fcfd78efa533291283 (patch)
tree0d3cb6dee45983ea81309d0f45107878e1ca7f0c
parentdc0744a423255c21a455446f9871ea42aca244fa (diff)
parent22961f81ddf642b24e45fdf9707dff06e17742a7 (diff)
downloadikiwiki-6c51b764bca2981b8962d7fcfd78efa533291283.tar
ikiwiki-6c51b764bca2981b8962d7fcfd78efa533291283.tar.gz
Merge branch 'ready/html5'
-rw-r--r--IkiWiki.pm2
-rw-r--r--IkiWiki/CGI.pm6
-rw-r--r--IkiWiki/Plugin/mirrorlist.pm2
-rw-r--r--debian/control2
-rwxr-xr-xt/html.t30
-rwxr-xr-xt/relativity.t189
-rwxr-xr-xt/wellformed.t50
-rw-r--r--templates/googleform.tmpl2
-rw-r--r--templates/page.tmpl12
-rw-r--r--templates/searchform.tmpl2
10 files changed, 77 insertions, 220 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 1043ef402..dfe89ad32 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -274,7 +274,7 @@ sub getsetup () {
html5 => {
type => "boolean",
default => 0,
- description => "generate HTML5?",
+ description => "use elements new in HTML5 like <section>?",
advanced => 0,
safe => 1,
rebuild => 1,
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index f448db6ef..61af830f8 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -67,9 +67,6 @@ sub cgitemplate ($$$;@) {
if (exists $params{page}) {
$page=delete $params{page};
$params{forcebaseurl}=urlto($page);
- if (! $config{html5}) {
- $params{forcebaseurl}=urlabs($params{forcebaseurl}, $topurl);
- }
}
run_hooks(pagetemplate => sub {
shift->(
@@ -81,9 +78,6 @@ sub cgitemplate ($$$;@) {
templateactions($template, "");
my $baseurl = baseurl();
- if (! $config{html5}) {
- $baseurl = urlabs($baseurl, $topurl),
- }
$template->param(
dynamic => 1,
diff --git a/IkiWiki/Plugin/mirrorlist.pm b/IkiWiki/Plugin/mirrorlist.pm
index b7e532485..5afd9ec1a 100644
--- a/IkiWiki/Plugin/mirrorlist.pm
+++ b/IkiWiki/Plugin/mirrorlist.pm
@@ -53,7 +53,7 @@ sub pagetemplate (@) {
sub mirrorlist ($) {
my $page=shift;
- return ($config{html5} ? '<nav id="mirrorlist">' : '<div>').
+ return ($config{html5} ? '<nav' : '<div').' id="mirrorlist">'.
(keys %{$config{mirrorlist}} > 1 ? gettext("Mirrors") : gettext("Mirror")).
": ".
join(", ",
diff --git a/debian/control b/debian/control
index 78bb68341..a5cac3c01 100644
--- a/debian/control
+++ b/debian/control
@@ -5,7 +5,7 @@ Build-Depends: perl, debhelper (>= 9)
Build-Depends-Indep: dpkg-dev (>= 1.9.0), libxml-simple-perl,
libtext-markdown-discount-perl,
libtimedate-perl, libhtml-template-perl,
- libhtml-scrubber-perl, wdg-html-validator,
+ libhtml-scrubber-perl,
libhtml-parser-perl, liburi-perl (>= 1.36), perlmagick, po4a (>= 0.34),
libfile-chdir-perl, libyaml-libyaml-perl, librpc-xml-perl,
libcgi-pm-perl, libcgi-session-perl, ghostscript,
diff --git a/t/html.t b/t/html.t
deleted file mode 100755
index 84c561fa8..000000000
--- a/t/html.t
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-use warnings;
-use strict;
-use Test::More;
-
-my @pages;
-
-BEGIN {
- @pages=qw(index features news plugins/map security);
- if (system("command -v validate >/dev/null") != 0) {
- plan skip_all => "html validator not present";
- }
- else {
- plan(tests => int @pages + 2);
- }
- use_ok("IkiWiki");
-}
-
-# Have to build the html pages first.
-# Note that just building them like this doesn't exersise all the possible
-# html that can be generated, in particular it misses some of the action
-# links at the top, etc.
-ok(system("make >/dev/null") == 0);
-
-foreach my $page (@pages) {
- print "# Validating $page\n";
- ok(system("validate html/$page.html") == 0);
-}
-
-# TODO: validate form output html
diff --git a/t/relativity.t b/t/relativity.t
index 054f8f664..a1f3ad830 100755
--- a/t/relativity.t
+++ b/t/relativity.t
@@ -59,7 +59,6 @@ cgiurl: $args{cgiurl}
$w3mmodeline
cgi_wrapper: t/tmp/ikiwiki.cgi
cgi_wrappermode: 0754
-html5: $args{html5}
# make it easier to test previewing
add_plugins:
- anonok
@@ -148,7 +147,6 @@ sub test_startup {
sub test_site1_perfectly_ordinary_ikiwiki {
write_setup_file(
- html5 => 0,
url => "http://example.com/wiki/",
cgiurl => "http://example.com/cgi-bin/ikiwiki.cgi",
);
@@ -157,77 +155,35 @@ sub test_site1_perfectly_ordinary_ikiwiki {
# url and cgiurl are on the same host so the cgiurl is host-relative
check_generated_content(qr{<a[^>]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"});
my %bits = parse_cgi_content(run_cgi());
- is($bits{basehref}, "http://example.com/wiki/");
+ like($bits{basehref}, qr{^(?:(?:http:)?//example\.com)?/wiki/$});
like($bits{stylehref}, qr{^(?:(?:http:)?//example.com)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.)/$});
like($bits{cgihref}, qr{^(?:(?:http:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
# when accessed via HTTPS, links are secure
%bits = parse_cgi_content(run_cgi(is_https => 1));
- is($bits{basehref}, "https://example.com/wiki/");
+ like($bits{basehref}, qr{^(?:(?:https:)?//example\.com)?/wiki/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
# when accessed via a different hostname, links stay on that host
%bits = parse_cgi_content(run_cgi(HTTP_HOST => 'staging.example.net'));
- is($bits{basehref}, "http://staging.example.net/wiki/");
+ like($bits{basehref}, qr{^(?:(?:http:)?//staging\.example\.net)?/wiki/$});
like($bits{stylehref}, qr{^(?:(?:http:)?//staging.example.net)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.)/$});
like($bits{cgihref}, qr{^(?:(?:http:)?//staging.example.net)?/cgi-bin/ikiwiki.cgi$});
# previewing a page
%bits = parse_cgi_content(run_cgi(is_preview => 1));
- is($bits{basehref}, "http://example.com/wiki/a/b/c/");
+ like($bits{basehref}, qr{^(?:(?:http:)?//example\.com)?/wiki/a/b/c/$});
like($bits{stylehref}, qr{^(?:(?:http:)?//example.com)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.\./\.\./\.\.)/$});
like($bits{cgihref}, qr{^(?:(?:http:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
-
- # in html5, the <base> is allowed to be relative, and we take full
- # advantage of that
- write_setup_file(
- html5 => 1,
- url => "http://example.com/wiki/",
- cgiurl => "http://example.com/cgi-bin/ikiwiki.cgi",
- );
- thoroughly_rebuild();
- check_cgi_mode_bits();
- # url and cgiurl are on the same host so the cgiurl is host-relative
- check_generated_content(qr{<a[^>]+href="/cgi-bin/ikiwiki.cgi\?do=prefs"});
-
- %bits = parse_cgi_content(run_cgi());
- is($bits{basehref}, "/wiki/");
- is($bits{stylehref}, "/wiki/style.css");
- is($bits{tophref}, "/wiki/");
- is($bits{cgihref}, "/cgi-bin/ikiwiki.cgi");
-
- # when accessed via HTTPS, links are secure - this is easy because under
- # html5 they're independent of the URL at which the CGI was accessed
- %bits = parse_cgi_content(run_cgi(is_https => 1));
- is($bits{basehref}, "/wiki/");
- is($bits{stylehref}, "/wiki/style.css");
- is($bits{tophref}, "/wiki/");
- is($bits{cgihref}, "/cgi-bin/ikiwiki.cgi");
-
- # when accessed via a different hostname, links stay on that host -
- # this is really easy in html5 because we can use relative URLs
- %bits = parse_cgi_content(run_cgi(HTTP_HOST => 'staging.example.net'));
- is($bits{basehref}, "/wiki/");
- is($bits{stylehref}, "/wiki/style.css");
- is($bits{tophref}, "/wiki/");
- is($bits{cgihref}, "/cgi-bin/ikiwiki.cgi");
-
- # previewing a page
- %bits = parse_cgi_content(run_cgi(is_preview => 1));
- is($bits{basehref}, "/wiki/a/b/c/");
- is($bits{stylehref}, "/wiki/style.css");
- like($bits{tophref}, qr{^(?:/wiki|\.\./\.\./\.\.)/$});
- is($bits{cgihref}, "/cgi-bin/ikiwiki.cgi");
}
sub test_site2_static_content_and_cgi_on_different_servers {
write_setup_file(
- html5 => 0,
url => "http://static.example.com/",
cgiurl => "http://cgi.example.com/ikiwiki.cgi",
);
@@ -238,14 +194,14 @@ sub test_site2_static_content_and_cgi_on_different_servers {
check_generated_content(qr{<a[^>]+href="(?:http:)?//cgi.example.com/ikiwiki.cgi\?do=prefs"});
my %bits = parse_cgi_content(run_cgi(SCRIPT_NAME => '/ikiwiki.cgi', HTTP_HOST => 'cgi.example.com'));
- like($bits{basehref}, qr{^http://static.example.com/$});
+ like($bits{basehref}, qr{^(?:(?:http:)?//static.example.com)?/$});
like($bits{stylehref}, qr{^(?:(?:http:)?//static.example.com)?/style.css$});
like($bits{tophref}, qr{^(?:http:)?//static.example.com/$});
like($bits{cgihref}, qr{^(?:(?:http:)?//cgi.example.com)?/ikiwiki.cgi$});
# when accessed via HTTPS, links are secure
%bits = parse_cgi_content(run_cgi(is_https => 1, SCRIPT_NAME => '/ikiwiki.cgi', HTTP_HOST => 'cgi.example.com'));
- like($bits{basehref}, qr{^https://static.example.com/$});
+ 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$});
@@ -253,7 +209,7 @@ sub test_site2_static_content_and_cgi_on_different_servers {
# when accessed via a different hostname, links to the CGI (only) should
# stay on that host?
%bits = parse_cgi_content(run_cgi(is_preview => 1, SCRIPT_NAME => '/ikiwiki.cgi', HTTP_HOST => 'staging.example.net'));
- like($bits{basehref}, qr{^http://static.example.com/a/b/c/$});
+ like($bits{basehref}, qr{^(?:http:)?//static\.example\.com/a/b/c/$});
like($bits{stylehref}, qr{^(?:(?:http:)?//static.example.com|\.\./\.\./\.\.)/style.css$});
like($bits{tophref}, qr{^(?:(?:http:)?//static.example.com|\.\./\.\./\.\.)/$});
like($bits{cgihref}, qr{^(?:(?:http:)?//(?:staging\.example\.net|cgi\.example\.com))?/ikiwiki.cgi$});
@@ -261,48 +217,10 @@ sub test_site2_static_content_and_cgi_on_different_servers {
local $TODO = "use self-referential CGI URL?";
like($bits{cgihref}, qr{^(?:(?:http:)?//staging.example.net)?/ikiwiki.cgi$});
}
-
- write_setup_file(
- html5 => 1,
- url => "http://static.example.com/",
- cgiurl => "http://cgi.example.com/ikiwiki.cgi",
- );
- thoroughly_rebuild();
- check_cgi_mode_bits();
- # url and cgiurl are not on the same host so the cgiurl has to be
- # protocol-relative or absolute
- check_generated_content(qr{<a[^>]+href="(?:http:)?//cgi.example.com/ikiwiki.cgi\?do=prefs"});
-
- %bits = parse_cgi_content(run_cgi(SCRIPT_NAME => '/ikiwiki.cgi', HTTP_HOST => 'cgi.example.com'));
- is($bits{basehref}, "//static.example.com/");
- is($bits{stylehref}, "//static.example.com/style.css");
- is($bits{tophref}, "//static.example.com/");
- is($bits{cgihref}, "//cgi.example.com/ikiwiki.cgi");
-
- # when accessed via HTTPS, links are secure - in fact they're exactly the
- # same as when accessed via HTTP
- %bits = parse_cgi_content(run_cgi(is_https => 1, SCRIPT_NAME => '/ikiwiki.cgi', HTTP_HOST => 'cgi.example.com'));
- is($bits{basehref}, "//static.example.com/");
- is($bits{stylehref}, "//static.example.com/style.css");
- is($bits{tophref}, "//static.example.com/");
- is($bits{cgihref}, "//cgi.example.com/ikiwiki.cgi");
-
- # when accessed via a different hostname, links to the CGI (only) should
- # stay on that host?
- %bits = parse_cgi_content(run_cgi(is_preview => 1, SCRIPT_NAME => '/ikiwiki.cgi', HTTP_HOST => 'staging.example.net'));
- is($bits{basehref}, "//static.example.com/a/b/c/");
- is($bits{stylehref}, "//static.example.com/style.css");
- is($bits{tophref}, "../../../");
- like($bits{cgihref}, qr{//(?:staging\.example\.net|cgi\.example\.com)/ikiwiki\.cgi});
- TODO: {
- local $TODO = "use self-referential CGI URL maybe?";
- is($bits{cgihref}, "//staging.example.net/ikiwiki.cgi");
- }
}
sub test_site3_we_specifically_want_everything_to_be_secure {
write_setup_file(
- html5 => 0,
url => "https://example.com/wiki/",
cgiurl => "https://example.com/cgi-bin/ikiwiki.cgi",
);
@@ -313,7 +231,7 @@ sub test_site3_we_specifically_want_everything_to_be_secure {
# when accessed via HTTPS, links are secure
my %bits = parse_cgi_content(run_cgi(is_https => 1));
- is($bits{basehref}, "https://example.com/wiki/");
+ like($bits{basehref}, qr{^(?:(?:https:)?//example\.com)?/wiki/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
@@ -331,25 +249,22 @@ sub test_site3_we_specifically_want_everything_to_be_secure {
# when accessed via a different hostname, links stay on that host
%bits = parse_cgi_content(run_cgi(is_https => 1, HTTP_HOST => 'staging.example.net'));
- is($bits{basehref}, "https://staging.example.net/wiki/");
+ like($bits{basehref}, qr{^(?:(?:https:)?//staging\.example\.net)?/wiki/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//staging.example.net)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//staging.example.net)?/cgi-bin/ikiwiki.cgi$});
# previewing a page
%bits = parse_cgi_content(run_cgi(is_preview => 1, is_https => 1));
- is($bits{basehref}, "https://example.com/wiki/a/b/c/");
+ like($bits{basehref}, qr{^(?:(?:https:)?//example\.com)?/wiki/a/b/c/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.\./\.\./\.\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
-
- # not testing html5: 0 here because that ends up identical to site 1
}
sub test_site4_cgi_is_secure_static_content_doesnt_have_to_be {
# (NetBSD wiki)
write_setup_file(
- html5 => 0,
url => "http://example.com/wiki/",
cgiurl => "https://example.com/cgi-bin/ikiwiki.cgi",
);
@@ -360,14 +275,15 @@ sub test_site4_cgi_is_secure_static_content_doesnt_have_to_be {
# when accessed via HTTPS, links are secure (to avoid mixed-content)
my %bits = parse_cgi_content(run_cgi(is_https => 1));
- is($bits{basehref}, "https://example.com/wiki/");
+ like($bits{basehref}, qr{^(?:(?:https:)?//example\.com)?/wiki/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
- # when not accessed via HTTPS, ???
+ # FIXME: when not accessed via HTTPS, should the static content be
+ # forced to https anyway? For now we accept either
%bits = parse_cgi_content(run_cgi());
- like($bits{basehref}, qr{^https?://example.com/wiki/$});
+ like($bits{basehref}, qr{^(?:(?:https?)?://example\.com)?/wiki/$});
like($bits{stylehref}, qr{^(?:(?:https?:)?//example.com)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:(?:https?://example.com)?/wiki|\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
@@ -376,7 +292,7 @@ sub test_site4_cgi_is_secure_static_content_doesnt_have_to_be {
%bits = parse_cgi_content(run_cgi(is_https => 1, HTTP_HOST => 'staging.example.net'));
# because the static and dynamic stuff is on the same server, we assume that
# both are also on the staging server
- like($bits{basehref}, qr{^https://staging.example.net/wiki/$});
+ like($bits{basehref}, qr{^(?:(?:https:)?//staging\.example\.net)?/wiki/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//staging.example.net)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:(?:(?:https:)?//staging.example.net)?/wiki|\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//(?:staging\.example\.net|example\.com))?/cgi-bin/ikiwiki.cgi$});
@@ -387,63 +303,15 @@ sub test_site4_cgi_is_secure_static_content_doesnt_have_to_be {
# previewing a page
%bits = parse_cgi_content(run_cgi(is_preview => 1, is_https => 1));
- is($bits{basehref}, "https://example.com/wiki/a/b/c/");
+ like($bits{basehref}, qr{^(?:(?:https:)?//example\.com)?/wiki/a/b/c/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
like($bits{tophref}, qr{^(?:/wiki|\.\./\.\./\.\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
-
- write_setup_file(
- html5 => 1,
- url => "http://example.com/wiki/",
- cgiurl => "https://example.com/cgi-bin/ikiwiki.cgi",
- );
- thoroughly_rebuild();
- check_cgi_mode_bits();
- # url and cgiurl are on the same host but different schemes
- check_generated_content(qr{<a[^>]+href="https://example.com/cgi-bin/ikiwiki.cgi\?do=prefs"});
-
- # when accessed via HTTPS, links are secure (to avoid mixed-content)
- %bits = parse_cgi_content(run_cgi(is_https => 1));
- is($bits{basehref}, "/wiki/");
- is($bits{stylehref}, "/wiki/style.css");
- is($bits{tophref}, "/wiki/");
- like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
-
- # when not accessed via HTTPS, ???
- %bits = parse_cgi_content(run_cgi());
- like($bits{basehref}, qr{^(?:https?://example.com)?/wiki/$});
- like($bits{stylehref}, qr{^(?:(?:https?:)?//example.com)?/wiki/style.css$});
- like($bits{tophref}, qr{^(?:(?:https?://example.com)?/wiki|\.)/$});
- like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
-
- # when accessed via a different hostname, links stay on that host
- %bits = parse_cgi_content(run_cgi(is_https => 1, HTTP_HOST => 'staging.example.net'));
- # because the static and dynamic stuff is on the same server, we assume that
- # both are also on the staging server
- is($bits{basehref}, "/wiki/");
- is($bits{stylehref}, "/wiki/style.css");
- like($bits{tophref}, qr{^(?:/wiki|\.)/$});
- like($bits{cgihref}, qr{^(?:(?:https:)?//(?:example\.com|staging\.example\.net))?/cgi-bin/ikiwiki.cgi$});
- TODO: {
- local $TODO = "this should really point back to itself but currently points to example.com";
- like($bits{cgihref}, qr{^(?:(?:https:)?//staging.example.net)?/cgi-bin/ikiwiki.cgi$});
- }
-
- # previewing a page
- %bits = parse_cgi_content(run_cgi(is_preview => 1, is_https => 1));
- is($bits{basehref}, "/wiki/a/b/c/");
- is($bits{stylehref}, "/wiki/style.css");
- like($bits{tophref}, qr{^(?:/wiki|\.\./\.\./\.\.)/$});
- like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
-
- # Deliberately not testing https static content with http cgiurl,
- # because that makes remarkably little sense.
}
sub test_site5_w3mmode {
# as documented in [[w3mmode]]
write_setup_file(
- html5 => 0,
url => undef,
cgiurl => "ikiwiki.cgi",
w3mmode => 1,
@@ -459,28 +327,10 @@ sub test_site5_w3mmode {
like($bits{cgihref}, qr{^(?:file://)?/\$LIB/ikiwiki-w3m.cgi/ikiwiki.cgi$});
like($bits{basehref}, qr{^(?:(?:file:)?//)?\Q$pwd\E/t/tmp/out/$});
like($bits{stylehref}, qr{^(?:(?:(?:file:)?//)?\Q$pwd\E/t/tmp/out|\.)/style.css$});
-
- write_setup_file(
- html5 => 1,
- url => undef,
- cgiurl => "ikiwiki.cgi",
- w3mmode => 1,
- );
- thoroughly_rebuild();
- check_cgi_mode_bits();
- # FIXME: does /$LIB/ikiwiki-w3m.cgi work under w3m?
- check_generated_content(qr{<a[^>]+href="(?:file://)?/\$LIB/ikiwiki-w3m.cgi/ikiwiki.cgi\?do=prefs"});
-
- %bits = parse_cgi_content(run_cgi(PATH_INFO => '/ikiwiki.cgi', SCRIPT_NAME => '/cgi-bin/ikiwiki-w3m.cgi'));
- like($bits{tophref}, qr{^(?:\Q$pwd\E/t/tmp/out|\.)/$});
- like($bits{cgihref}, qr{^(?:file://)?/\$LIB/ikiwiki-w3m.cgi/ikiwiki.cgi$});
- like($bits{basehref}, qr{^(?:(?:file:)?//)?\Q$pwd\E/t/tmp/out/$});
- like($bits{stylehref}, qr{^(?:(?:(?:file:)?//)?\Q$pwd\E/t/tmp/out|\.)/style.css$});
}
sub test_site6_behind_reverse_proxy {
write_setup_file(
- html5 => 0,
url => "https://example.com/wiki/",
cgiurl => "https://example.com/cgi-bin/ikiwiki.cgi",
reverse_proxy => 1,
@@ -495,18 +345,15 @@ sub test_site6_behind_reverse_proxy {
my %bits = parse_cgi_content(run_cgi(HTTP_HOST => 'localhost'));
like($bits{tophref}, qr{^(?:/wiki|\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
- is($bits{basehref}, "https://example.com/wiki/");
+ like($bits{basehref}, qr{^(?:(?:https:)?//example\.com)?/wiki/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
# previewing a page
%bits = parse_cgi_content(run_cgi(is_preview => 1, HTTP_HOST => 'localhost'));
like($bits{tophref}, qr{^(?:/wiki|\.\./\.\./\.\.)/$});
like($bits{cgihref}, qr{^(?:(?:https:)?//example.com)?/cgi-bin/ikiwiki.cgi$});
- is($bits{basehref}, "https://example.com/wiki/a/b/c/");
+ like($bits{basehref}, qr{^(?:(?:https)?://example\.com)?/wiki/a/b/c/$});
like($bits{stylehref}, qr{^(?:(?:https:)?//example.com)?/wiki/style.css$});
-
- # not testing html5: 1 because it would be the same as site 1 -
- # the reverse_proxy config option is unnecessary under html5
}
test_startup();
diff --git a/t/wellformed.t b/t/wellformed.t
new file mode 100755
index 000000000..cee0ff3be
--- /dev/null
+++ b/t/wellformed.t
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Cwd qw();
+use File::Find;
+use Test::More;
+
+plan(skip_all => "XML::Parser not available")
+ unless eval q{use XML::Parser (); 1;};
+
+use IkiWiki;
+
+ok(system("make >/dev/null") == 0);
+
+chdir("html") || die "chdir: $!";
+
+sub wanted {
+ my $file = $_;
+ return if -d $file;
+ $file =~ s{^\./}{};
+ return if $file !~ m/\.html$/;
+ if (eval {
+ XML::Parser->new()->parsefile($file);
+ 1;
+ }) {
+ pass($file);
+ }
+ elsif ($file =~ m{^(?:
+ # user-contributed, contains explicit <br>
+ plugins/contrib/gallery |
+ # use templatebody when branchable.com has been upgraded
+ templates/ |
+ # malformed content in <pre> not escaped by discount
+ tips/convert_mediawiki_to_ikiwiki
+ # user-contributed, content is anyone's guess
+ users/ |
+ )}x) {
+ TODO: {
+ local $TODO = $@;
+ fail($file);
+ }
+ }
+}
+
+find({
+ no_chdir => 1,
+ wanted => \&wanted,
+}, '.');
+
+done_testing;
diff --git a/templates/googleform.tmpl b/templates/googleform.tmpl
index b1c3078fb..155a08155 100644
--- a/templates/googleform.tmpl
+++ b/templates/googleform.tmpl
@@ -3,6 +3,6 @@
<div>
<input name="sitesearch" value="<TMPL_VAR URL>" type="hidden" />
<input name="q" value="" id="searchbox" size="16" maxlength="255" type="text"
- <TMPL_IF HTML5>placeholder="search"</TMPL_IF> />
+ placeholder="search" />
</div>
</form>
diff --git a/templates/page.tmpl b/templates/page.tmpl
index c709c4f85..301c737fe 100644
--- a/templates/page.tmpl
+++ b/templates/page.tmpl
@@ -1,9 +1,5 @@
-<TMPL_IF HTML5><!DOCTYPE html>
-<html>
-<TMPL_ELSE><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
-</TMPL_IF>
<head>
<TMPL_IF DYNAMIC>
<TMPL_IF FORCEBASEURL><base href="<TMPL_VAR FORCEBASEURL>" /><TMPL_ELSE>
@@ -134,7 +130,7 @@
<div id="pagebody">
-<TMPL_IF HTML5><section id="content" role="main"><TMPL_ELSE><div id="content"></TMPL_IF>
+<TMPL_IF HTML5><section<TMPL_ELSE><div</TMPL_IF> id="content" role="main">
<TMPL_VAR CONTENT>
<TMPL_IF HTML5></section><TMPL_ELSE></div></TMPL_IF>
@@ -146,7 +142,7 @@
<TMPL_UNLESS DYNAMIC>
<TMPL_IF COMMENTS>
-<TMPL_IF HTML5><section id="comments" role="complementary"><TMPL_ELSE><div id="comments"></TMPL_IF>
+<TMPL_IF HTML5><section<TMPL_ELSE><div</TMPL_IF> id="comments" role="complementary">
<TMPL_VAR COMMENTS>
<TMPL_IF ADDCOMMENTURL>
<div class="addcomment">
@@ -161,7 +157,7 @@
</div>
-<TMPL_IF HTML5><footer id="footer" class="pagefooter" role="contentinfo"><TMPL_ELSE><div id="footer" class="pagefooter"></TMPL_IF>
+<TMPL_IF HTML5><footer<TMPL_ELSE><div</TMPL_IF> id="footer" class="pagefooter" role="contentinfo">
<TMPL_UNLESS DYNAMIC>
<TMPL_IF HTML5><nav id="pageinfo"><TMPL_ELSE><div id="pageinfo"></TMPL_IF>
diff --git a/templates/searchform.tmpl b/templates/searchform.tmpl
index cb65d124c..8cdf745f9 100644
--- a/templates/searchform.tmpl
+++ b/templates/searchform.tmpl
@@ -1,6 +1,6 @@
<form method="get" action="<TMPL_VAR SEARCHACTION>" id="searchform">
<div>
<input type="text" id="searchbox" name="P" value="" size="16"
-<TMPL_IF HTML5>placeholder="search"</TMPL_IF> />
+ placeholder="search" />
</div>
</form>