Convert Usevote to UTF-8.

Signed-off-by: Thomas Hochstein <thh@thh.name>
This commit is contained in:
Thomas Hochstein 2026-02-08 15:06:05 +01:00
parent 162c5aefda
commit a60ea76fe8
8 changed files with 31 additions and 7 deletions

View file

@ -3,9 +3,12 @@
package UVreadmail; package UVreadmail;
use utf8;
use open qw(:std :encoding(UTF-8));
use strict; use strict;
use UVconfig; use UVconfig;
use UVmessage; use UVmessage;
use Encode qw(decode :fallbacks);
use MIME::QuotedPrint; use MIME::QuotedPrint;
use MIME::Base64; use MIME::Base64;
use MIME::Parser; use MIME::Parser;
@ -200,6 +203,7 @@ sub process {
# extract address and name # extract address and name
my $from = $head->get('From') || ''; my $from = $head->get('From') || '';
utf8::decode($from); # fix double encoding
if ($from =~ /\s*([^<]\S+\@\S+[^>]) \((.+)\)/) { if ($from =~ /\s*([^<]\S+\@\S+[^>]) \((.+)\)/) {
($voter_addr, $voter_name) = ($1, $2); ($voter_addr, $voter_name) = ($1, $2);
@ -240,6 +244,13 @@ sub process {
$body = $entity->stringify_body; $body = $entity->stringify_body;
} }
# body: charset conversion to Perl internal representation
my $ct = $head->get('Content-Type') || '';
if ($ct =~ /^text\/plain;.*charset=\"?([-a-zA-Z0-9]+)\"?/i) {
my $charset = $1;
$body = decode($charset, $body, FB_CROAK);
}
my $h_date = $head->get('Date') || ''; my $h_date = $head->get('Date') || '';
chomp $h_date; chomp $h_date;

View file

@ -3,6 +3,8 @@
package UVsendmail; package UVsendmail;
use utf8;
use open qw(:std :utf8);
use strict; use strict;
use UVconfig; use UVconfig;
use UVtemplate; use UVtemplate;
@ -239,7 +241,7 @@ sub mimeencode {
$word =~ s/\n//g; $word =~ s/\n//g;
my $encword; my $encword;
if ($word =~ /[\x7F-\xFF]/) { if ($word =~ /[\x7F-\xFF]/) {
$encword = MIME::Words::encode_mimeword($word, 'Q', 'ISO-8859-1'); $encword = MIME::Words::encode_mimeword($word, 'Q', 'UTF-8');
} elsif (length($word) > 75) { } elsif (length($word) > 75) {
$encword = MIME::Words::encode_mimeword($word, 'Q', 'us-ascii'); $encword = MIME::Words::encode_mimeword($word, 'Q', 'us-ascii');
} else { } else {

View file

@ -44,6 +44,8 @@ einer Liste immer 60 Zeichen lang ist um ansehnliche Tabellen auszugeben.
#---------------------------------------------------------------------- #----------------------------------------------------------------------
use utf8;
use open qw(:std :utf8);
use strict; use strict;
use vars qw( $VERSION $functions @dirs); use vars qw( $VERSION $functions @dirs);
use UVconfig; use UVconfig;
@ -370,10 +372,10 @@ sub _parse_rules{
sub _strip_chars{ sub _strip_chars{
my $line = $_[0] || return; my $line = $_[0] || return;
# führenden whitespace entfernen # führenden whitespace entfernen
$$line =~ s/^\s+//; $$line =~ s/^\s+//;
# kommentare bis zum nächsten Zeilenumbruch entfernen # kommentare bis zum nächsten Zeilenumbruch entfernen
$$line =~ s/^#.*$//m; $$line =~ s/^#.*$//m;
} }
@ -618,8 +620,8 @@ sub _parse_comment{
my $count = 1; my $count = 1;
while($string && $count) { while($string && $count) {
$string =~ s/^[^\[\]\\]+//s; # alles außer Klammern und Backslash wegwerfen $string =~ s/^[^\[\]\\]+//s; # alles außer Klammern und Backslash wegwerfen
$string =~ s/^\\.//; # alles gesperrte löschen $string =~ s/^\\.//; # alles gesperrte löschen
$count++ if $string =~ s/^\[//; $count++ if $string =~ s/^\[//;
$count-- if $string =~ s/^\]//; $count-- if $string =~ s/^\]//;
@ -775,7 +777,7 @@ Sonderzeichen oder Leerzeichen uebergeben werden muessen diese gequotet
werden. Dazu kann ' also auch " verwendet werden. werden. Dazu kann ' also auch " verwendet werden.
Die Funktionen geben im Allgemeinen einen String zurueck. Im Rahmen Die Funktionen geben im Allgemeinen einen String zurueck. Im Rahmen
von Listen können auch Arrays uebergeben werden. von Listen können auch Arrays uebergeben werden.
Die erste Funktion duerfte ueblicherweise 'value' sein. Sie gibt den Die erste Funktion duerfte ueblicherweise 'value' sein. Sie gibt den
des angegeben Schluessel zurueck, der dann von den folgenden Funktionen des angegeben Schluessel zurueck, der dann von den folgenden Funktionen

View file

@ -12,5 +12,5 @@ Message-ID: [$msgid]
Date: [$date] Date: [$date]
X-Automated-Message: generated by [$usevote-version] X-Automated-Message: generated by [$usevote-version]
MIME-Version: 1.0 MIME-Version: 1.0
Content-Type: text/plain; charset\=iso-8859-1 Content-Type: text/plain; charset\=UTF-8
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit

View file

@ -21,6 +21,8 @@
# written in C). Not all functions of Usevote/UseVoteGer 3.x are implemented! # written in C). Not all functions of Usevote/UseVoteGer 3.x are implemented!
############################################################################### ###############################################################################
use utf8;
use open qw(:std :utf8);
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use FindBin qw($Bin); use FindBin qw($Bin);

View file

@ -20,6 +20,8 @@
# written in C). Not all functions of Usevote/UseVoteGer 3.x are implemented! # written in C). Not all functions of Usevote/UseVoteGer 3.x are implemented!
############################################################################### ###############################################################################
use utf8;
use open qw(:std :utf8);
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use Digest::MD5 qw(md5_hex); use Digest::MD5 qw(md5_hex);

View file

@ -20,6 +20,8 @@
# written in C). Not all functions of Usevote/UseVoteGer 3.x are implemented! # written in C). Not all functions of Usevote/UseVoteGer 3.x are implemented!
############################################################################### ###############################################################################
use utf8;
use open qw(:std :encoding(UTF-8));
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use Digest::MD5 qw(md5_hex); use Digest::MD5 qw(md5_hex);

View file

@ -21,6 +21,8 @@
# written in C). Not all functions of Usevote/UseVoteGer 3.x are implemented! # written in C). Not all functions of Usevote/UseVoteGer 3.x are implemented!
############################################################################### ###############################################################################
use utf8;
use open qw(:std :utf8);
use strict; use strict;
use Getopt::Long; use Getopt::Long;
use Text::Wrap qw(wrap $columns); use Text::Wrap qw(wrap $columns);
@ -330,6 +332,7 @@ sub process_vote {
$voter_name = $3; $voter_name = $3;
$voter_name =~ s/^\s+//; # strip leading spaces $voter_name =~ s/^\s+//; # strip leading spaces
$voter_name =~ s/\s+$//; # strip trailing spaces $voter_name =~ s/\s+$//; # strip trailing spaces
utf8::decode($voter_name); # fix double encoding
} }
if ($voter_name) { if ($voter_name) {