Hello.

I have found the fix:
l...@crocodile:~/src/wiki$ diff -u /usr/share/perl5/IkiWiki/CGI.pm.orig 
/usr/share/perl5/IkiWiki/CGI.pm
--- /usr/share/perl5/IkiWiki/CGI.pm.orig        2010-04-30 22:00:41.000000000 
+0700
+++ /usr/share/perl5/IkiWiki/CGI.pm     2010-04-30 23:11:51.000000000 +0700
@@ -42,7 +42,10 @@
 sub redirect ($$) {
        my $q=shift;
        eval q{use URI};
-       my $url=URI->new(shift);
+       eval q{use utf8};
+       my $a = shift;
+       $a = encode_utf8($a);
+       my $url=URI->new($a);
        if (! $config{w3mmode}) {
                print $q->redirect($url);
        }
l...@crocodile:~/src/wiki$     

How it works: URI->new tries to escape all chars at function _init at
/usr/share/perl5/URI.pm:76. But it does not use any function for that,
it use internal map which contains codes from 0..255 (see
/usr/share/perl5/URI/Escape.pm:157). My fix simply convert russian chars
into sequence of bytes in utf8 encoding and pass it to URI. And then URI
correctly encode all russian chars:

(see enviroment from prev email)
$ ~/public_html/cgi-bin/ikiwiki.cgi
Status: 302 Found
Location: 
/~lan/people/%D0%9A%D1%83%D0%B7%D0%BD%D0%B5%D1%86%D0%BE%D0%B2%D0%B0_%D0%9B%D1%8E%D0%B1%D0%BE%D0%B2%D1%8C_%D0%9D%D0%B8%D0%BA%D0%BE%D0%BB%D0%B0%D0%B5%D0%B2%D0%BD%D0%B0/

l...@crocodile:~/src/wiki$                           

I will store this fix until someone will fix this at mainstream.  

Joey Hess <[email protected]> writes:

> Alexander Litvinov wrote:
>> I have installe ikiwiki with cgi support. When I edit page with
>> russian char at it I have a problem: cgi script does not redirects me
>> to updated page. Or recentchanges don't allow me to view the page.
>> 
>> For example: I have a page "people/Кузнецова Любовь Николаевна".
>> Recentchanges show it's link as:
>> http://127.0.0.1:8011/~lan/cgi-bin/ikiwiki.cgi?page=people%2F%D0%9A%D1%83%D0%B7%D0%BD%D0%B5%D1%86%D0%BE%D0%B2%D0%B0_%D0%9B%D1%8E%D0%B1%D0%BE%D0%B2%D1%8C_%D0%9D%D0%B8%D0%BA%D0%BE%D0%BB%D0%B0%D0%B5%D0%B2%D0%BD%D0%B0&do=goto
>> 
>> It is a correct link, spaces are replaced by undercore (_). But when I
>> click on in at the browser I get: "Not Found The requested URL
>> /~lan/people/__/ was not found on this server. Apache/2.2.9 (Debian)
>> Server at 127.0.0.1 Port 8011"
>> 
>> ikiwiki.cgi strips all russian chars from page name and tries to show
>> it !
>
> I tried to reproduce this:
>
> j...@gnu:~/src/joeywiki/sandbox>echo test > Кузнецова_Любовь_Николаевна.mdwn
> j...@gnu:~/src/joeywiki/sandbox>git add Кузнецова_Любовь_Николаевна.mdwn
> j...@gnu:~/src/joeywiki/sandbox>git commit -m add
> [master 612b3df] add
>  1 files changed, 1 insertions(+), 0 deletions(-)
>   create mode 100644
>   
> "sandbox/\320\232\321\203\320\267\320\275\320\265\321\206\320\276\320\262\320\260_\320\233\321\216\320\261\320\276\320\262\321\214_\320\235\320\270\320\272\320\276\320\273\320\260\320\265\320\262\320\275\320\260.mdwn"
>
> Resulting html in recentchanges:
>
> <a 
> href="http://gnu.kitenet.net/~joey/ikiwiki.cgi?page=sandbox%2F%D0%9A%D1%83%D0%B7%D0%BD%D0%B5%D1%86%D0%BE%D0%B2%D0%B0_%D0%9B%D1%8E%D0%B1%D0%BE%D0%B2%D1%8C_%D0%9D%D0%B8%D0%BA%D0%BE%D0%BB%D0%B0%D0%B5%D0%B2%D0%BD%D0%B0&amp;do=goto";
>  rel="nofollow">sandbox/Кузнецова Любовь Николаевна</a> 
>
> When I click on the link, it correctly takes me to the page.
>
>
> Perhaps you need to configure your ikiwiki to consistently use a utf-8
> locale. I have in my ikiwiki.setup:
>
>         locale => 'en_US.UTF-8',
>
> And that locale is uncommented in /etc/locale.gen. 'ru_RU.UTF-8' should
> work as well.
>
> -- 
> see shy jo



--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to