]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/mercurial.pm
fix new perl warning
[git.ikiwiki.info.git] / IkiWiki / Plugin / mercurial.pm
index 102b4692b805024ec02dc78a7db09896436e3d2b..8da4ceb07ada8f026e908be1004d060e9e21adeb 100644 (file)
@@ -5,6 +5,7 @@ use warnings;
 use strict;
 use IkiWiki;
 use Encode;
+use URI::Escape q{uri_escape_utf8};
 use open qw{:utf8 :std};
 
 sub import {
@@ -180,7 +181,6 @@ sub rcs_commit_helper (@) {
        $ENV{HGENCODING} = 'utf-8';
 
        my $user="Anonymous";
-       my $nickname;
        if (defined $params{session}) {
                if (defined $params{session}->param("name")) {
                        $user = $params{session}->param("name");
@@ -189,6 +189,7 @@ sub rcs_commit_helper (@) {
                        $user = $params{session}->remote_addr();
                }
 
+               my $nickname=$user;
                if (defined $params{session}->param("nickname")) {
                        $nickname=encode_utf8($params{session}->param("nickname"));
                        $nickname=~s/\s+/_/g;
@@ -265,7 +266,8 @@ sub rcs_recentchanges ($) {
 
                foreach my $file (split / /,$info->{files}) {
                        my $diffurl = defined $config{diffurl} ? $config{'diffurl'} : "";
-                       $diffurl =~ s/\[\[file\]\]/$file/go;
+                       my $efile = uri_escape_utf8($file);
+                       $diffurl =~ s/\[\[file\]\]/$efile/go;
                        $diffurl =~ s/\[\[r2\]\]/$info->{changeset}/go;
 
                        push @pages, {
@@ -361,15 +363,8 @@ sub findtimes ($$) {
                print $tmpl_fh 'file = "{file}\\n"' . "\n";
                
                foreach my $line (run_or_die('hg', 'log', '--style', $tmpl_filename)) {
-                       # {date} gives output on the form
-                       # 1310694511.0-7200
-                       # where the first number is UTC Unix timestamp with one
-                       # decimal (decimal always 0, at least on my system)
-                       # followed by local timezone offset from UTC in
-                       # seconds.
-                       if (! defined $date && $line =~ /^\d+\.\d[+-]\d*$/) {
-                               $line =~ s/^(\d+).*/$1/;
-                               $date=$line;
+                       if (! defined $date && $line =~ /^(\d+)/) {
+                               $date=$1;
                        }
                        elsif (! length $line) {
                                $date=undef;