From c4e222f59103107041ddcb778cc153eaf8ca492b Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 11 Jul 2006 20:45:33 +0000 Subject: add --- doc/patchqueue/decode-from.mdwn | 106 +++++++++++++++++++++++++++++++++++++ doc/patchqueue/webcommit-from.mdwn | 79 +++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 doc/patchqueue/decode-from.mdwn create mode 100644 doc/patchqueue/webcommit-from.mdwn (limited to 'doc') diff --git a/doc/patchqueue/decode-from.mdwn b/doc/patchqueue/decode-from.mdwn new file mode 100644 index 000000000..4d385f67a --- /dev/null +++ b/doc/patchqueue/decode-from.mdwn @@ -0,0 +1,106 @@ +From [[Faidon]]: + +I consolidated all decode_utf8 in FormBuilder's fields +to make the code more readable and avoid future mistakes. The patch +seems to work and for the first time I have a UTF-8 username ;-) +I think that with this patch and the previous one about locales, we're +done with UTF-8 support. Yay! + + Index: IkiWiki/CGI.pm + =================================================================== + --- IkiWiki/CGI.pm (revision 904) + +++ IkiWiki/CGI.pm (working copy) + @@ -41,6 +41,17 @@ + return 0; + } #}}} + + +sub decode_form_utf8 ($) { #{{{ + + my $form = shift; + + foreach my $f ($form->field) { + + next if Encode::is_utf8(scalar $form->field($f)); + + $form->field(name => $f, + + value => decode_utf8($form->field($f)), + + force => 1, + + ); + + } + +} #}}} + + + sub cgi_recentchanges ($) { #{{{ + my $q=shift; + + @@ -166,6 +177,8 @@ + } + + if ($form->submitted && $form->validate) { + + decode_form_utf8($form); + + + if ($form->submitted eq 'Login') { + $session->param("name", $form->field("name")); + if (defined $form->field("do") && + @@ -282,6 +295,8 @@ + value => userinfo_get($user_name, "locked_pages")); + } + + + decode_form_utf8($form); + + + if ($form->submitted eq 'Logout') { + $session->delete(); + redirect($q, $config{url}); + @@ -326,7 +341,7 @@ + ); + my @buttons=("Save Page", "Preview", "Cancel"); + + - # This untaint is safe because titlepage removes any problimatic + + # This untaint is safe because titlepage removes any problematic + # characters. + my ($page)=decode_utf8($form->param('page')); + $page=titlepage(possibly_foolish_untaint(lc($page))); + @@ -367,16 +382,16 @@ + force => 1); + } + + + decode_form_utf8($form); + + + if ($form->submitted eq "Cancel") { + redirect($q, "$config{url}/".htmlpage($page)); + return; + } + elsif ($form->submitted eq "Preview") { + require IkiWiki::Render; + - # Apparently FormBuilder doesn't not treat input as + - # utf-8, so decode from it. + - my $content=decode_utf8($form->field('editcontent')); + - my $comments=decode_utf8($form->field('comments')); + + my $content=$form->field('editcontent'); + + my $comments=$form->field('comments'); + $form->field(name => "editcontent", + value => $content, force => 1); + $form->field(name => "comments", + @@ -463,8 +478,7 @@ + # save page + page_locked($page, $session); + + - # Decode utf-8 since FormBuilder does not + - my $content=decode_utf8($form->field('editcontent')); + + my $content=$form->field('editcontent'); + + $content=~s/\r\n/\n/g; + $content=~s/\r/\n/g; + @@ -480,7 +494,7 @@ + } + if (defined $form->field('comments') && + length $form->field('comments')) { + - $message.=": ".decode_utf8($form->field('comments')); + + $message.=": ".$form->field('comments'); + } + + if ($config{rcs}) { + @@ -499,7 +513,7 @@ + force => 1); + $form->tmpl_param("page_conflict", 1); + $form->field("editcontent", value => $conflict, force => 1); + - $form->field(name => "comments", value => decode_utf8($form->field('comments')), force => 1); + + $form->field(name => "comments", value => $form->field('comments'), force => 1); + $form->field("do", "edit)"); + $form->tmpl_param("page_select", 0); + $form->field(name => "page", type => 'hidden'); diff --git a/doc/patchqueue/webcommit-from.mdwn b/doc/patchqueue/webcommit-from.mdwn new file mode 100644 index 000000000..9855c5ce9 --- /dev/null +++ b/doc/patchqueue/webcommit-from.mdwn @@ -0,0 +1,79 @@ +From [[Faidon]]: + +Match 'web commit from' in SVN and git, these are web +commits too. Show the IP instead of the user 'www-data' (which is kind +of security fix too, since the user Apache is running as was visible). + +Note that the git backend patch is untested. +Recai, could you test it? (if Joey finds the change acceptable that is). + + Index: IkiWiki/Rcs/svn.pm + =================================================================== + --- IkiWiki/Rcs/svn.pm (revision 904) + +++ IkiWiki/Rcs/svn.pm (working copy) + @@ -7,7 +7,7 @@ + + package IkiWiki; + + -my $svn_webcommit=qr/^web commit by (\w+):?(.*)/; + +my $svn_webcommit=qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/; + + sub svn_info ($$) { #{{{ + my $field=shift; + @@ -136,8 +136,8 @@ + my $committype="web"; + if (defined $message[0] && + $message[0]->{line}=~/$svn_webcommit/) { + - $user="$1"; + - $message[0]->{line}=$2; + + $user=defined $2 ? "$2" : "$3"; + + $message[0]->{line}=$4; + } + else { + $committype="svn"; + @@ -178,8 +178,8 @@ + chomp $user; + my $message=`svnlook log $config{svnrepo} -r $rev`; + if ($message=~/$svn_webcommit/) { + - $user="$1"; + - $message=$2; + + $user=defined $2 ? "$2" : "$3"; + + $message=$4; + } + + my @changed_pages; + Index: IkiWiki/Rcs/git.pm + =================================================================== + --- IkiWiki/Rcs/git.pm (revision 904) + +++ IkiWiki/Rcs/git.pm (working copy) + @@ -12,7 +12,7 @@ + my $master_branch = 'master'; # working branch + my $sha1_pattern = qr/[0-9a-fA-F]{40}/; # pattern to validate Git sha1sums + my $dummy_commit_msg = 'dummy commit'; # message to skip in recent changes + -my $web_commit_msg = qr/^web commit by (\w+):?(.*)/; # pattern for web commits + +my $web_commit_msg = qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/; + + sub _safe_git (&@) { #{{{ + # Start a child process safely without resorting /bin/sh. + @@ -377,8 +377,8 @@ + + if (defined $message[0] && + $message[0]->{line} =~ m/$web_commit_msg/) { + - $user = "$1"; + - $message[0]->{line} = $2; + + $user=defined $2 ? "$2" : "$3"; + + $message[0]->{line}=$4; + } else { + $type ="git"; + $user = $ci->{'author_username'}; + @@ -426,8 +426,8 @@ + + my ($user, $message); + if (@{ $ci->{'comment'} }[0] =~ m/$web_commit_msg/) { + - $user = "$1"; + - $message = $2; + + $user = defined $2 ? "$2" : "$3"; + + $message = $4; + } else { + $user = $ci->{'author_username'}; + $message = join "\n", @{ $ci->{'comment'} }; -- cgit v1.2.3