comments: Deal with users entering unqualified or partial urls.
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 26 Dec 2008 19:07:19 +0000 (14:07 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 26 Dec 2008 19:07:19 +0000 (14:07 -0500)
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.

IkiWiki/Plugin/comments.pm
debian/changelog

index 0ae9eefe320f2b634781375b8c57927844a8d2cc..d8318d3e3afa309e7893fd994a8bbf8730fe0c3a 100644 (file)
@@ -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 {
index 19b8cbdf7adaf0df3fa69803b9ca1f7ce53cf60e..96a70fcc9a8809c259d0f313b51145b992ed5483 100644 (file)
@@ -4,6 +4,7 @@ ikiwiki (2.72) UNRELEASED; urgency=low
   * Add deprecation warning for GlobLists, which will stop working in 3.0.
   * camelcase: Add camelcase_ignore setting.
   * googlecalendar: Add runtime deprecation warning.
+  * comments: Deal with users entering unqualified or partial urls.
 
  -- Joey Hess <joeyh@debian.org>  Mon, 22 Dec 2008 19:02:16 -0500