aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2008-12-26 14:07:19 -0500
committerJoey Hess <joey@gnu.kitenet.net>2008-12-26 14:07:19 -0500
commit9db06329c98e1a390bbb6323de02dc7e2f45f1f8 (patch)
tree9be1a22b818a00a94bce43959e6b7a14ef898598 /IkiWiki/Plugin
parent0d406010ff8ffb8d891318bbaf6b6de1e2cb2578 (diff)
downloadikiwiki-9db06329c98e1a390bbb6323de02dc7e2f45f1f8.tar
ikiwiki-9db06329c98e1a390bbb6323de02dc7e2f45f1f8.tar.gz
comments: Deal with users entering unqualified or partial urls.
People seem to be able to expect to enter www.foo.com and get away with it. The resulting my.wiki/www.foo.com link was not ideal. To fix it, use URI::Heuristic to expand such things into a real url. It even looks up hostnames in the DNS if necessary.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/comments.pm13
1 files changed, 11 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 0ae9eefe3..d8318d3e3 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -198,8 +198,17 @@ sub preprocess {
$pagestate{$page}{meta}{author} = $params{claimedauthor};
}
- if (defined $params{url} and safeurl($params{url})) {
- $pagestate{$page}{meta}{authorurl} = $params{url};
+ if (defined $params{url}) {
+ my $url=$params{url};
+
+ eval q{use URI::Heuristic};
+ if (! $@) {
+ $url=URI::Heuristic::uf_uristr($url);
+ }
+
+ if (safeurl($url)) {
+ $pagestate{$page}{meta}{authorurl} = $url;
+ }
}
}
else {