]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/No_link_for_blog_items_when_filename_contains_a_colon.mdwn
remove test
[ikiwiki.git] / doc / bugs / No_link_for_blog_items_when_filename_contains_a_colon.mdwn
1 Since upgrading from Ikiwiki 2.20 to 2.32.3 (from Debian Lenny), I don't get hyperlinks to items which have a colon in their name anymore. This applies to both the normal and the archive view. Before the update, the links have been created as relative links, so they weren't usable either as the browser tried to take the part before the colon as protocol specification (as in e.g. `http:`). Iirc, this applied to the archive view only, links in the normal view were ok (will check this out again if it's important). Is there a way to quote each colon as %xy in the hyperlinks? Perhaps it's only a problem with my config, and not an actual bug...?
2
3 EDIT: I just found that in this wiki under <http://ikiwiki.info/bugs/done/> the entry "mailto: links not properly generated in rss/atom feeds" also doesn't have a hyperlink - at least it's not a problem with my config only ;-)
4
5 [[madduck]]: I traced this down to `htmlscrubber`. If disabled, it works. If
6 enabled, then `$safe_url_regexp` determines the URL unsafe because of the
7 colon and hence removes the `src` attribute.
8
9 Digging into this, I find that [[!rfc 3986]] pretty much discourages colons in
10 filenames:
11
12 > A path segment that contains a colon character (e.g., "this:that") cannot be
13 > used as the first segment of a relative-path reference, as it would be
14 > mistaken for a scheme name.  Such a segment must be preceded by
15 > a dot-segment (e.g., "./this:that") to make a relative- path reference.
16
17 The solution seems not to use colons.
18
19 In any case, `htmlscrubber` should get a new regexp, courtesy of dato:
20 `[^:]+($|\/)`. I have tested and verified this.
21
22 [Commit/patch
23 be0b4f60](http://git.madduck.net/v/code/ikiwiki.git?a=commit;h=be0b4f603f918444b906e42825908ddac78b7073) fixes this.
24
25
26 **July 21 2008:** I update this bug report as it still seems to be an issue: E.g. when creating a subpage whose name contains
27 a colon by inserting an appropriate wikilink in the parent page: the new page can be created using that link, but afterwards
28 there won't be a link to this page. Like madduck said above it seems to be htmlscrubber removing this link. However everything
29 works fine if the same page is being linked to from another subpage because in that case the resulting link starts with `../`.
30
31 At the moment I see two possible solutions:
32
33 1. let all relative links at least start with `./`. I haven't tested this.
34
35 2. Escape the colon in page titles. I created the following patch which worked for me:
36
37         --- IkiWiki.pm.2.53-save        2008-07-08 15:56:38.000000000 +0200
38         +++ IkiWiki.pm  2008-07-21 20:41:35.000000000 +0200
39         @@ -477,13 +477,13 @@
40
41          sub titlepage ($) { #{{{
42                 my $title=shift;
43         -       $title=~s/([^-[:alnum:]:+\/.])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
44         +       $title=~s/([^-[:alnum:]+\/.])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
45                 return $title;
46          } #}}}
47
48          sub linkpage ($) { #{{{
49                 my $link=shift;
50         -       $link=~s/([^-[:alnum:]:+\/._])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
51         +       $link=~s/([^-[:alnum:]+\/._])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
52                 return $link;
53          } #}}}
54
55 What do you think about that? Does the patch have any side-effects I didn't see?
56
57 > What version of ikiwiki are you seeing it with? I fixed another
58 > colon-bug in version 2.53; you'd need to rebuild any affected wikis to
59 > get the fix. The relevant code is in `beautify_urlpath`, where it adds
60 > "./" in front of every relative url. An example of it working in this
61 > very wiki is a link to [[colon:problem]] --[[Joey]]