From a965e024302c900df9a77ed9eccc8609d2986571 Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Wed, 29 Jun 2011 18:35:29 -0400
Subject: [PATCH] Bugfix for wikilink containing an email address not showing
 up in  brokenlinks list.

---
 IkiWiki/Plugin/link.pm                                   | 8 +++-----
 debian/changelog                                         | 2 ++
 .../emails_should_not_be_considered_as_broken_links.mdwn | 9 +++++++++
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/IkiWiki/Plugin/link.pm b/IkiWiki/Plugin/link.pm
index f6c3573f7..87e06ca89 100644
--- a/IkiWiki/Plugin/link.pm
+++ b/IkiWiki/Plugin/link.pm
@@ -64,23 +64,21 @@ sub checkconfig () {
 	}
 }
 
-sub is_externallink ($$;$$) {
+sub is_externallink ($$;$) {
 	my $page = shift;
 	my $url = shift;
 	my $anchor = shift;
-	my $force = shift;
 	
 	if (defined $anchor) {
 		$url.="#".$anchor;
 	}
 
-	if (! $force && $url =~ /$email_regexp/) {
+	if ($url =~ /$email_regexp/) {
 		# url looks like an email address, so we assume it
 		# is supposed to be an external link if there is no
 		# page with that name.
 		return (! (bestlink($page, linkpage($url))))
 	}
-
 	return ($url =~ /$url_regexp/)
 }
 
@@ -140,7 +138,7 @@ sub scan (@) {
 	my $content=$params{content};
 
 	while ($content =~ /(?<!\\)$link_regexp/g) {
-		if (! is_externallink($page, $2, $3, 1)) {
+		if (! is_externallink($page, $2, $3)) {
 			add_link($page, linkpage($2));
 		}
 	}
diff --git a/debian/changelog b/debian/changelog
index b25e9a596..ece9df882 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -29,6 +29,8 @@ ikiwiki (3.20110609) UNRELEASED; urgency=low
     mode) (smcv)
   * inline: Handle obfuscated urls, such as the mailto urls generated by
     markdown when forcing urls absolute.
+  * Bugfix for wikilink containing an email address not showing up in 
+    brokenlinks list.
 
  -- Joey Hess <joeyh@debian.org>  Thu, 09 Jun 2011 10:06:44 -0400
 
diff --git a/doc/bugs/emails_should_not_be_considered_as_broken_links.mdwn b/doc/bugs/emails_should_not_be_considered_as_broken_links.mdwn
index 90d9fceff..353c3653d 100644
--- a/doc/bugs/emails_should_not_be_considered_as_broken_links.mdwn
+++ b/doc/bugs/emails_should_not_be_considered_as_broken_links.mdwn
@@ -3,3 +3,12 @@ The [[ikiwiki/directive/brokenlinks]] directive lists emails when used inside [[
 [[!brokenlinks pages="*@* and !recentchanges"]]
 
 > Weird.  The bug, imho, is that `\[[email-address]]` results in a marked-up email address. I think marking up email addresses into hyperlinks should be handled by a markup plugin (e.g. markdown), not by the wikilink parser. I feel the same way for external links, but it appears [this is all by design](http://source.ikiwiki.branchable.com/?p=source.git;a=commitdiff;h=07a08122d926ab6b7741c94bc6c0038ffe0113fb). — [[Jon]]
+
+>> I belive this was done for compatability with the wikicreole plugin.
+>> Since in creole, a wikilink can contain an email or full html link, 
+>> and it was easier to make ikiwiki's wikilinks do so too, rather
+>> than put entirely different link handling into creole.
+>>
+>> Anyway, I've fixed this, although it leaves some weirdness if a page
+>> is created with a name like an email address and that same email address
+>> was previously used for external links. [[done]] --[[Joey]] 
-- 
2.39.5