Commit ba8cb62d authored by Jesse Vincent's avatar Jesse Vincent
Browse files

Working on better Encode::Guessing; fixing error reporting on scrip failure;...

Working on better Encode::Guessing; fixing error reporting on scrip failure; fixed a missing require of

File::Temp; hopefully better catching of missing modules
parent 69889121
......@@ -22,8 +22,6 @@
#
#
# END LICENSE BLOCK
#
# DO NOT HAND-EDIT the file named 'Makefile'. This file is autogenerated.
# Have a look at "configure" and "Makefile.in" instead
......
A rough sketch of what's coming for 2.2. to be fleshed out later.
likely it will be "saveable preferences, saveable searches,
easier upgrades, freeform custom fields, integrated cvs, enhanced
mailgate, wapRT and templated responses. oh. and some
reporting.
---
Errata for RT 2.x can be found at http://fsck.com/rt2/NoAuth/Errata.html
A list of all open issues, including those which haven't been added
to the official Errata lists, can be found at
http://fsck.com/rt2/NoAuth/Buglist.html
If you want to look at bugs in more detail, you may need to login as guest with a password of 'guest'
......@@ -266,12 +266,12 @@ sub _ClassAccessible {
eval "require RT::ACE_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/ACE_Overlay.pm}) {
die $@;
};
eval "require RT::ACE_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/ACE_Local.pm}) {
die $@;
};
......
......@@ -77,12 +77,12 @@ sub NewItem {
}
eval "require RT::ACL_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/ACL_Overlay.pm}) {
die $@;
};
eval "require RT::ACL_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/ACL_Local.pm}) {
die $@;
};
......
......@@ -225,7 +225,7 @@ my $approvals =
my $groups = RT::Groups->new($RT::SystemUser);
$groups->LimitToUserDefinedGroups();
$groups->Limit(FIELD => "Name", OPERATOR => "=", VALUE => "$name");
$groups->WithMember($TransactionObj->CreatorObj->Id);
$groups->WithMember($Transaction->CreatorObj->Id);
my $groupid = $groups->First->Id;
......
# BEGIN LICENSE BLOCK
#
#
# Copyright (c) 1996-2002 Jesse Vincent <jesse@bestpractical.com>
#
#
# (Except where explictly superceded by other copyright notices)
#
#
# This work is made available to you under the terms of Version 2 of
# the GNU General Public License. A copy of that license should have
# been provided with this software, but in any event can be snarfed
# from www.gnu.org
#
#
# This work is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
#
#
#
# Unless otherwise specified, all modifications, corrections or
# extensions to this work which alter its source code become the
# property of Best Practical Solutions, LLC when submitted for
# inclusion in the work.
#
#
#
#
# END LICENSE BLOCK
# Portions Copyright 2000 Tobias Brox <tobix@cpan.org>
......
......@@ -334,12 +334,12 @@ sub _ClassAccessible {
eval "require RT::Attachment_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/Attachment_Overlay.pm}) {
die $@;
};
eval "require RT::Attachment_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/Attachment_Local.pm}) {
die $@;
};
......
......@@ -77,12 +77,12 @@ sub NewItem {
}
eval "require RT::Attachments_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/Attachments_Overlay.pm}) {
die $@;
};
eval "require RT::Attachments_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/Attachments_Local.pm}) {
die $@;
};
......
......@@ -220,12 +220,12 @@ sub _ClassAccessible {
eval "require RT::CachedGroupMember_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CachedGroupMember_Overlay.pm}) {
die $@;
};
eval "require RT::CachedGroupMember_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CachedGroupMember_Local.pm}) {
die $@;
};
......
......@@ -77,12 +77,12 @@ sub NewItem {
}
eval "require RT::CachedGroupMembers_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CachedGroupMembers_Overlay.pm}) {
die $@;
};
eval "require RT::CachedGroupMembers_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CachedGroupMembers_Local.pm}) {
die $@;
};
......
......@@ -302,12 +302,12 @@ sub _ClassAccessible {
eval "require RT::CustomField_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CustomField_Overlay.pm}) {
die $@;
};
eval "require RT::CustomField_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CustomField_Local.pm}) {
die $@;
};
......
......@@ -256,12 +256,12 @@ sub _ClassAccessible {
eval "require RT::CustomFieldValue_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CustomFieldValue_Overlay.pm}) {
die $@;
};
eval "require RT::CustomFieldValue_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CustomFieldValue_Local.pm}) {
die $@;
};
......
......@@ -83,12 +83,12 @@ sub NewItem {
}
eval "require RT::CustomFieldValues_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CustomFieldValues_Overlay.pm}) {
die $@;
};
eval "require RT::CustomFieldValues_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CustomFieldValues_Local.pm}) {
die $@;
};
......
......@@ -83,12 +83,12 @@ sub NewItem {
}
eval "require RT::CustomFields_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CustomFields_Overlay.pm}) {
die $@;
};
eval "require RT::CustomFields_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/CustomFields_Local.pm}) {
die $@;
};
......
......@@ -220,12 +220,12 @@ sub _ClassAccessible {
eval "require RT::Group_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/Group_Overlay.pm}) {
die $@;
};
eval "require RT::Group_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/Group_Local.pm}) {
die $@;
};
......
......@@ -151,12 +151,12 @@ sub _ClassAccessible {
eval "require RT::GroupMember_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/GroupMember_Overlay.pm}) {
die $@;
};
eval "require RT::GroupMember_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/GroupMember_Local.pm}) {
die $@;
};
......
......@@ -77,12 +77,12 @@ sub NewItem {
}
eval "require RT::GroupMembers_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/GroupMembers_Overlay.pm}) {
die $@;
};
eval "require RT::GroupMembers_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/GroupMembers_Local.pm}) {
die $@;
};
......
......@@ -77,12 +77,12 @@ sub NewItem {
}
eval "require RT::Groups_Overlay";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/Groups_Overlay.pm}) {
die $@;
};
eval "require RT::Groups_Local";
if ($@ && $@ !~ /^Can't locate/) {
if ($@ && $@ !~ qr{^Can't locate RT/Groups_Local.pm}) {
die $@;
};
......
......@@ -221,72 +221,84 @@ This method doesn't return anything meaningful.
=cut
sub SetMIMEEntityToEncoding {
my ($entity, $enc) = (shift, shift);
if ($entity->is_multipart) {
RT::I18N::SetMIMEEntityToEncoding($_, $enc) foreach $entity->parts;
} else {
my ($head, $body) = ($entity->head, $entity->bodyhandle);
my ($mime_type, $charset) =
($head->mime_type, $head->mime_attr("content-type.charset") || "");
# the entity is not text, nothing to do with it.
return unless ($mime_type eq 'text/plain');
# the entity is text and has charset setting, try convert
# message body into $enc
my @lines = $body->as_lines or return;
if (!$charset) {
if ( @RT::EmailInputEncodings and eval { require Encode::Guess; 1 } ) {
Encode::Guess->set_suspects(@RT::EmailInputEncodings);
my $decoder = Encode::Guess->guess($body->as_string);
if (ref $decoder) {
$charset = $decoder->name;
$RT::Logger->debug("Guessed encoding: $charset");
}
else {
$charset = 'utf-8';
$RT::Logger->warning("Cannot Encode::Guess: $decoder; fallback to utf-8");
}
}
else {
$charset = 'utf-8';
}
}
# one and only normalization
$charset = 'utf-8' if $charset eq 'utf8';
$enc = 'utf-8' if $enc eq 'utf8';
if ($enc ne $charset) {
eval {
$RT::Logger->debug("Converting '$charset' to '$enc'");
# NOTE:: see the comments at the end of the sub.
Encode::_utf8_off($lines[$_]) foreach (0 .. $#lines);
my ( $entity, $enc ) = ( shift, shift );
if ($enc eq 'utf-8') {
$lines[$_] = Encode::decode($charset, $lines[$_]) foreach (0 .. $#lines);
}
else {
Encode::from_to($lines[$_], $charset => $enc) foreach (0 .. $#lines);
}
};
if ($@) {
$RT::Logger->error("Encoding error: ".$@);
}
}
elsif ($enc eq 'utf-8') {
Encode::_utf8_on($lines[$_]) foreach (0 .. $#lines);
}
my $new_body = MIME::Body::InCore->new(\@lines);
# set up the new entity
$head->mime_attr("content-type.charset" => $enc);
$entity->bodyhandle($new_body);
if ( $entity->is_multipart ) {
RT::I18N::SetMIMEEntityToEncoding( $_, $enc ) foreach $entity->parts;
}
else {
my ( $head, $body ) = ( $entity->head, $entity->bodyhandle );
my ( $mime_type, $charset ) =
( $head->mime_type, $head->mime_attr("content-type.charset") || "" );
# the entity is not text, nothing to do with it.
# TODO: should we be converting ANY text/ type? autrijus?
return unless ( $mime_type =~ /^text\/plain$/ );
# the entity is text and has charset setting, try convert
# message body into $enc
my @lines = $body->as_lines or return;
if ( !$charset ) {
if ( @RT::EmailInputEncodings
and eval { require Encode::Guess; 1 } ) {
Encode::Guess->set_suspects(@RT::EmailInputEncodings);
my $decoder = Encode::Guess->guess( $body->as_string );
if ( ref $decoder ) {
$charset = $decoder->name;
$RT::Logger->debug("Guessed encoding: $charset");
}
else {
$charset = 'utf-8';
$RT::Logger->warning( "Cannot Encode::Guess: $decoder; fallback to utf-8");
}
}
else {
$charset = 'utf-8';
}
}
# one and only normalization
$charset = 'utf-8' if $charset eq 'utf8';
$enc = 'utf-8' if $enc eq 'utf8';
if ( $enc ne $charset ) {
eval {
$RT::Logger->debug("Converting '$charset' to '$enc'");
# NOTE:: see the comments at the end of the sub.
Encode::_utf8_off( $lines[$_] ) foreach ( 0 .. $#lines );
if ( $enc eq 'utf-8' ) {
$lines[$_] = Encode::decode( $charset, $lines[$_] ) foreach ( 0 .. $#lines );
}
else {
Encode::from_to( $lines[$_], $charset => $enc ) foreach ( 0 .. $#lines );
}
};
if ($@) {
$RT::Logger->error( "Encoding error: " . $@ . " defaulting to ISO-8859-1 -> UTF-8");
eval {
Encode::from_to( $lines[$_], 'iso-8859-1' => $enc ) foreach ( 0 .. $#lines );
};
if ($@) {
$RT::Logger->crit( "Totally failed to convert to utf-8: ".$@. " I give up");
}
}
}
elsif ( $enc eq 'utf-8' ) {
Encode::_utf8_on( $lines[$_] ) foreach ( 0 .. $#lines );
}
my $new_body = MIME::Body::InCore->new( \@lines );
# set up the new entity
$head->mime_attr( "content-type.charset" => $enc );
$entity->bodyhandle($new_body);
}
}
......
# BEGIN LICENSE BLOCK
#
#
# Copyright (c) 1996-2002 Jesse Vincent <jesse@bestpractical.com>
#
#
# (Except where explictly superceded by other copyright notices)
#
#
# This work is made available to you under the terms of Version 2 of
# the GNU General Public License. A copy of that license should have
# been provided with this software, but in any event can be snarfed
# from www.gnu.org
#
#
# This work is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
#
#
#
# Unless otherwise specified, all modifications, corrections or
# extensions to this work which alter its source code become the
# property of Best Practical Solutions, LLC when submitted for
# inclusion in the work.
#
#
#
#
# END LICENSE BLOCK
package RT::Interface::Email::Auth::MailFrom;
use RT::Interface::Email qw(ParseSenderAddressFromHead CreateUser);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment