Accéder au contenu.
Menu Sympa

fr - Re: [sympa-fr] Problèmes

Objet : Pour les administrateurs de serveurs de listes utilisant le logiciel Sympa

Archives de la liste

Chronologique Discussions  
  • From: adresse@cachée
  • To: adresse@cachée
  • Subject: Re: [sympa-fr] Problèmes
  • Date: Fri, 13 Jun 2008 19:11:51 +0200

En attendant une solution j'ai fait la modif suivante dans le fichier tools.pl
:


####################### AJOUT DE LA FONTION qencode_filename_upgrade
## Q-Encode web file name
sub qencode_filename_upgrade {
my $filename = shift;

## We don't use MIME::Words here because it does not encode properly
Unicode
## Check if string is already Q-encoded first
## Also check if the string contains 8bit chars
unless ($filename =~ /\=\?UTF-8\?/ ||
$filename =~ /^[\x00-\x7f]*$/) {

## Don't encode elements such as .desc. or .url or .moderate or
.extension
my $part = $filename;
my ($leading, $trailing);
$leading = $1 if ($part =~ s/^(\.desc\.)//); ## leading .desc
$trailing = $1 if ($part =~ s/((\.\w+)+)$//); ## trailing .xx

## We use low-level subroutine instead of to prevent
Encode::encode('MIME-Q')
## Otherwise \n are inserted

my $encoded_part =
&Encode::encode_utf8(&Encode::MIME::Header::_encode_q($part));

$filename = $leading.$encoded_part.$trailing;
}

return $filename;
}

#######################MODIFICATION DE LA FONCTION qencode_filename
## Q-Encode web file name
sub qencode_filename {
my $filename = shift;

## We don't use MIME::Words here because it does not encode properly
Unicode
## Check if string is already Q-encoded first
## Also check if the string contains 8bit chars
unless ($filename =~ /\=\?UTF-8\?/ ||
$filename =~ /^[\x00-\x7f]*$/) {

## Don't encode elements such as .desc. or .url or .moderate or
.extension
my $part = $filename;
my ($leading, $trailing);
$leading = $1 if ($part =~ s/^(\.desc\.)//); ## leading .desc
$trailing = $1 if ($part =~ s/((\.\w+)+)$//); ## trailing .xx

## We use low-level subroutine instead of to prevent
Encode::encode('MIME-Q')
## Otherwise \n are inserted

my $encoded_part =
&Encode::encode_utf8(&Encode::MIME::Header::_encode_q(&Encode::decode_utf8($part)));

$filename = $leading.$encoded_part.$trailing;
}

return $filename;
}

####################### ET MODIFICATION DE LA FONCTION SUIVANTE
sub qencode_hierarchy {
my $dir = shift; ## Root directory
my $original_encoding = shift; ## Suspected original encoding of filenames

my $count;
my @all_files;
&tools::list_dir($dir, \@all_files, $original_encoding);

foreach my $f_struct (reverse @all_files) {

next unless ($f_struct->{'filename'} =~ /[^\x00-\x7f]/); ## At least
one 8bit char

my $new_filename = $f_struct->{'filename'};
my $encoding = $f_struct->{'encoding'};
Encode::from_to($new_filename, $encoding, 'utf8') if $encoding;

## Q-encode filename to escape chars with accents
$new_filename = &tools::qencode_filename_upgrade($new_filename);

my $orig_f = $f_struct->{'directory'}.'/'.$f_struct->{'filename'};
my $new_f = $f_struct->{'directory'}.'/'.$new_filename;

## Rename the file using utf8
&do_log('notice', "Renaming %s to %s", $orig_f, $new_f);
unless (rename $orig_f, $new_f) {
&do_log('err', "Failed to rename %s to %s : %s", $orig_f, $new_f,
$!);
next;
}
$count++;
}



Archives gérées par MHonArc 2.6.19+.

Haut de le page