aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-03-07 09:48:59 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-03-07 09:48:59 +0000
commitb365d864c507c9f6e3374c1fb7c854ddb495aeae (patch)
treee8e4f848c6374d64394421a3c0b28da622896ba3
parentb39495f5015d0e5037db7682a2dc625abb26c5b8 (diff)
downloadikiwiki-b365d864c507c9f6e3374c1fb7c854ddb495aeae.tar
ikiwiki-b365d864c507c9f6e3374c1fb7c854ddb495aeae.tar.gz
My fix to support encoded underscores in page titles broke links to pages
with underscores in their filenames, since the link code also used titlepage. Create a new linkpage function and have the link code use that instead.
-rw-r--r--IkiWiki.pm12
-rw-r--r--IkiWiki/CGI.pm11
-rw-r--r--IkiWiki/Render.pm2
-rw-r--r--debian/changelog2
-rw-r--r--po/ikiwiki.pot16
-rwxr-xr-xt/linkify.t3
6 files changed, 29 insertions, 17 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 763f24e6c..385d16a56 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -376,6 +376,12 @@ sub titlepage ($) { #{{{
return $title;
} #}}}
+sub linkpage ($) { #{{{
+ my $link=shift;
+ $link=~s/([^-[:alnum:]:+\/._])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
+ return $link;
+} #}}}
+
sub cgiurl (@) { #{{{
my %params=@_;
@@ -422,6 +428,8 @@ sub htmllink ($$$;@) { #{{{
my $link=shift;
my %opts=@_;
+print STDERR "bestlink $lpage $link\n" if $lpage eq "roadmap" && $link =~/rcs/;
+
my $bestlink;
if (! $opts{forcesubpage}) {
$bestlink=bestlink($lpage, $link);
@@ -496,8 +504,8 @@ sub linkify ($$$) { #{{{
$content =~ s{(\\?)$config{wiki_link_regexp}}{
defined $2
- ? ( $1 ? "[[$2|$3]]" : htmllink($lpage, $page, titlepage($3), anchor => $4, linktext => pagetitle($2)))
- : ( $1 ? "[[$3]]" : htmllink($lpage, $page, titlepage($3), anchor => $4))
+ ? ( $1 ? "[[$2|$3]]" : htmllink($lpage, $page, linkpage($3), anchor => $4, linktext => pagetitle($2)))
+ : ( $1 ? "[[$3]]" : htmllink($lpage, $page, linkpage($3), anchor => $4))
}eg;
return $content;
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index b884a32f2..aeccd31ac 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -286,9 +286,10 @@ sub cgi_prefs ($$) { #{{{
}
} #}}}
-sub cgi_editpage ($$) { #{{{
+sub cgi_editpage ($$;$) { #{{{
my $q=shift;
my $session=shift;
+ my $blogpost=shift;
my @fields=qw(do rcsinfo subpage from page type editcontent comments
newfile);
@@ -322,6 +323,9 @@ sub cgi_editpage ($$) { #{{{
# characters.
my ($page)=$form->field('page');
$page=titlepage(possibly_foolish_untaint($page));
+ if ($blogpost) {
+ $page=~s/(\/)/"__".ord($1)."__"/eg;
+ }
if (! defined $page || ! length $page || file_pruned($page, $config{srcdir}) || $page=~/^\//) {
error("bad page name");
}
@@ -682,7 +686,6 @@ sub cgi (;$$) { #{{{
}
elsif ($do eq 'blog') {
my $page=decode_utf8($q->param('title'));
- $page=~s/\// /g; # remove slashes to avoid accidental subpages
# if the page already exists, munge it to be unique
my $from=$q->param('from');
my $add="";
@@ -691,9 +694,9 @@ sub cgi (;$$) { #{{{
$add++;
}
$q->param('page', $page.$add);
- # now run same as create
+ # now run same as create, except escape slashes too
$q->param('do', 'create');
- cgi_editpage($q, $session);
+ cgi_editpage($q, $session, 1);
}
elsif ($do eq 'postsignin') {
error(gettext("login failed, perhaps you need to turn on cookies?"));
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index 3545df05a..80c99e430 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -157,7 +157,7 @@ sub scan ($) { #{{{
my @links;
while ($content =~ /(?<!\\)$config{wiki_link_regexp}/g) {
- push @links, titlepage($2);
+ push @links, linkpage($2);
}
if ($config{discussion}) {
# Discussion links are a special case since they're
diff --git a/debian/changelog b/debian/changelog
index 18d1462e9..4243e527c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -18,7 +18,7 @@ ikiwiki (1.45) UNRELEASED; urgency=low
* Fix some nasty issues with page name escaping during previewing
(introduced in 1.44).
- -- Joey Hess <joeyh@debian.org> Wed, 7 Mar 2007 03:59:39 -0500
+ -- Joey Hess <joeyh@debian.org> Wed, 7 Mar 2007 04:47:40 -0500
ikiwiki (1.44) unstable; urgency=low
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index f53c6bd4e..4e70f520c 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-03-07 02:29-0500\n"
+"POT-Creation-Date: 2007-03-07 04:47-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -24,33 +24,33 @@ msgstr ""
msgid "Preferences saved."
msgstr ""
-#: ../IkiWiki/CGI.pm:340
+#: ../IkiWiki/CGI.pm:344
#, perl-format
msgid "%s is not an editable page"
msgstr ""
-#: ../IkiWiki/CGI.pm:427 ../IkiWiki/Plugin/brokenlinks.pm:24
+#: ../IkiWiki/CGI.pm:431 ../IkiWiki/Plugin/brokenlinks.pm:24
#: ../IkiWiki/Plugin/inline.pm:172 ../IkiWiki/Plugin/opendiscussion.pm:17
#: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:97
#: ../IkiWiki/Render.pm:165
msgid "discussion"
msgstr ""
-#: ../IkiWiki/CGI.pm:473
+#: ../IkiWiki/CGI.pm:477
#, perl-format
msgid "creating %s"
msgstr ""
-#: ../IkiWiki/CGI.pm:490 ../IkiWiki/CGI.pm:526 ../IkiWiki/CGI.pm:570
+#: ../IkiWiki/CGI.pm:494 ../IkiWiki/CGI.pm:530 ../IkiWiki/CGI.pm:574
#, perl-format
msgid "editing %s"
msgstr ""
-#: ../IkiWiki/CGI.pm:667
+#: ../IkiWiki/CGI.pm:671
msgid "You are banned."
msgstr ""
-#: ../IkiWiki/CGI.pm:699
+#: ../IkiWiki/CGI.pm:702
msgid "login failed, perhaps you need to turn on cookies?"
msgstr ""
@@ -486,7 +486,7 @@ msgstr ""
#. translators: preprocessor directive name,
#. translators: the second a page name, the
#. translators: third a number.
-#: ../IkiWiki.pm:561
+#: ../IkiWiki.pm:569
#, perl-format
msgid "%s preprocessing loop detected on %s at depth %i"
msgstr ""
diff --git a/t/linkify.t b/t/linkify.t
index 18b47dcb7..1b297433a 100755
--- a/t/linkify.t
+++ b/t/linkify.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 15;
+use Test::More tests => 16;
BEGIN { use_ok("IkiWiki"); }
@@ -68,6 +68,7 @@ sub links_text ($$) {
ok(links_to("bar", linkify("foo", "foo", "link to [[bar]] ok", ["foo", "bar"])), "ok link");
+ok(links_to("bar_baz", linkify("foo", "foo", "link to [[bar_baz]] ok", ["foo", "bar_baz"])), "ok link");
ok(not_links_to("bar", linkify("foo", "foo", "link to \\[[bar]] ok", ["foo", "bar"])), "escaped link");
ok(links_to("page=bar", linkify("foo", "foo", "link to [[bar]] ok", ["foo"])), "broken link");
ok(links_to("bar", linkify("foo", "foo", "link to [[baz]] and [[bar]] ok", ["foo", "baz", "bar"])), "dual links");