From b1fb11a5ffed25281b596315f7a33c38c9c2b400 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 10 Feb 2008 17:17:44 -0500 Subject: [PATCH] * meta: Check that the urls provided for authorurl, permalink, and openid are safe and can't contain javascript. --- IkiWiki/Plugin/meta.pm | 27 +++++++++++++++++++++------ debian/changelog | 5 +++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 621e87674..74b630afc 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -38,6 +38,17 @@ sub scrub ($) { #{{{ } } #}}} +sub safeurl ($) { #{{{ + my $url=shift; + if (exists $IkiWiki::Plugin::htmlscrubber::{safe_url_regexp} && + defined $IkiWiki::Plugin::htmlscrubber::safe_url_regexp) { + return $url=~/$IkiWiki::Plugin::htmlscrubber::safe_url_regexp/; + } + else { + return 1; + } +} #}}} + sub htmlize ($$$) { #{{{ my $page = shift; my $destpage = shift; @@ -88,7 +99,7 @@ sub preprocess (@) { #{{{ # fallthorough } elsif ($key eq 'authorurl') { - $pagestate{$page}{meta}{authorurl}=$value; + $pagestate{$page}{meta}{authorurl}=$value if safeurl($value); # fallthrough } @@ -106,8 +117,10 @@ sub preprocess (@) { #{{{ } } elsif ($key eq 'permalink') { - $pagestate{$page}{meta}{permalink}=$value; - push @{$metaheaders{$page}}, scrub(''); + if (safeurl($value)) { + $pagestate{$page}{meta}{permalink}=$value; + push @{$metaheaders{$page}}, scrub(''); + } } elsif ($key eq 'stylesheet') { my $rel=exists $params{rel} ? $params{rel} : "alternate stylesheet"; @@ -124,12 +137,14 @@ sub preprocess (@) { #{{{ "\" type=\"text/css\" />"; } elsif ($key eq 'openid') { - if (exists $params{server}) { + if (exists $params{server} && safeurl($params{server})) { push @{$metaheaders{$page}}, ''; } - push @{$metaheaders{$page}}, ''; + if (safeurl($value)) { + push @{$metaheaders{$page}}, ''; + } } elsif ($key eq 'redir') { return "" if $page ne $destpage; diff --git a/debian/changelog b/debian/changelog index de58d2d7d..b539761ff 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ ikiwiki (2.32.3) UNRELEASED; urgency=low + [ Josh Triplett ] * Do not allow the about: URI scheme; some browsers interpret about: URIs like a limited version of data: URIs. In particular, some versions of Internet Explorer interpret arbitrary HTML content in @@ -7,6 +8,10 @@ ikiwiki (2.32.3) UNRELEASED; urgency=low * Also filter the attributes cite, longdesc, and usemap, which can contain URIs. + [ Joey Hess ] + * meta: Check that the urls provided for authorurl, permalink, and openid + are safe and can't contain javascript. + -- Josh Triplett Sun, 10 Feb 2008 13:59:00 -0800 ikiwiki (2.31.2) unstable; urgency=high -- 2.39.2