[Rt-commit] rt branch, 4.0/i18n-guess, updated. rt-3.9.7-1130-gc937578
Ruslan Zakirov
ruz at bestpractical.com
Thu Dec 30 16:35:46 EST 2010
The branch, 4.0/i18n-guess has been updated
via c937578469ec42b700ceaaca00b4c27a4d3a595a (commit)
via 69ad522020af40af8f5595162032d080024f01a5 (commit)
from 5dbdd9c34ee95b410531c220d6aca330cde46af3 (commit)
Summary of changes:
lib/RT/Config.pm | 28 ++++++++++++++++++++++++++++
t/api/i18n_guess.t | 16 +++++++++++++++-
2 files changed, 43 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 69ad522020af40af8f5595162032d080024f01a5
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Dec 31 00:33:41 2010 +0300
our EncodeGuess can pick less prioritized encoding
diff --git a/t/api/i18n_guess.t b/t/api/i18n_guess.t
index 88e48e6..139ec1a 100644
--- a/t/api/i18n_guess.t
+++ b/t/api/i18n_guess.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use RT::Test tests => 13;
+use RT::Test tests => 16;
use Encode qw(encode);
@@ -13,6 +13,7 @@ use constant HAS_ENCODE_DETECT => do { local $@; eval { require Encode::Detect::
my $string = "\x{442}\x{435}\x{441}\x{442} \x{43f}\x{43e}\x{434}\x{434}\x{435}\x{440}\x{436}\x{43a}\x{430}";
sub guess {
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
is( RT::I18N::_GuessCharset( Encode::encode($_[0], $_[1]) ), $_[2] || $_[0], "$_[0] guesses as @{[$_[2]||$_[0]]}" );
}
@@ -47,6 +48,19 @@ SKIP: {
}
}
+# windows-1251 is an alias for cp1251, post load check cleanups array for us
+RT->Config->Set(EmailInputEncodings => qw(UTF-8 windows-1251 koi8-r));
+RT->Config->PostLoadCheck;
+SKIP: {
+ skip "No Encode::Guess", 3 unless HAS_ENCODE_GUESS;
+ guess('utf-8', $string);
+ guess('cp1251', $string);
+ {
+ local $TODO = "Encode::Guess can't distinguish cp1251 from koi8-r";
+ guess('koi8-r', $string);
+ }
+}
+
RT->Config->Set(EmailInputEncodings => qw(* UTF-8 cp1251 koi8-r));
SKIP: {
skip "No Encode::Detect", 3 unless HAS_ENCODE_DETECT;
commit c937578469ec42b700ceaaca00b4c27a4d3a595a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Dec 31 00:35:00 2010 +0300
de-alias EmailInputEncodings in PostLoadCheck
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 64798a2..4a87382 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -536,6 +536,34 @@ our %META = (
'You can change the site default in your %Lifecycles config.');
}
},
+ EmailInputEncodings => {
+ Type => 'ARRAY',
+ PostLoadCheck => sub {
+ my $self = shift;
+ my $value = $self->Get('EmailInputEncodings');
+ return unless $value && @$value;
+
+ my %seen;
+ foreach my $encoding ( grep defined && length, splice @$value ) {
+ next if $seen{ $encoding }++;
+ if ( $encoding eq '*' ) {
+ unshift @$value, '*';
+ next;
+ }
+
+ my $canonic = Encode::resolve_alias( $encoding );
+ unless ( $canonic ) {
+ warn "Unknown encoding '$encoding' in \@EmailInputEncodings option";
+ }
+ elsif ( $seen{ $canonic }++ ) {
+ next;
+ }
+ else {
+ push @$value, $canonic;
+ }
+ }
+ },
+ }
);
my %OPTIONS = ();
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list