Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode::MIME::Header clean up #68

Merged
merged 22 commits into from Oct 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2a2cc91
taint.t: Add tests for not tainted strings
pali Oct 6, 2016
de4ce95
Encode::MIME::Header: Test function use_ok() must be called in BEGIN …
pali Oct 6, 2016
cf1e1c0
Encode::MIME::Header: Add test cases with multiple input strings
pali Oct 6, 2016
2d6c29d
Encode::MIME::Header: Use one coding style and cleanup namespace
pali Oct 6, 2016
3cbf3e8
Encode::MIME::Header: decode: In strict mode do not try to decode inv…
pali Oct 6, 2016
0dd732b
Encode::MIME::Header: decode: In non strict mode allows spaces in MIM…
pali Oct 6, 2016
66c91a4
Encode::MIME::Header: decode: Do not drop trailing empty lines
pali Oct 6, 2016
614e348
Encode::MIME::Header: encode: Do not generate too long MIME words
pali Oct 6, 2016
2d7aaee
Encode::MIME::Name: Fix MIME name for ISO-2022-JP-1
pali Oct 6, 2016
0367a8f
Encode: Add function find_mime_encoding()
pali Oct 6, 2016
494a455
Encode::MIME::Header: Fix encoding and decoding of inner strings
pali Oct 6, 2016
68934e5
Encode::MIME::Header: encode: Implement full support for check flags
pali Oct 6, 2016
ec880c9
Encode::MIME::Header: encode: Remove use of const SINGLE and call fun…
pali Oct 6, 2016
7cb2405
Encode::MIME::Header: decode: Rewrite decoder and implement full supp…
pali Oct 6, 2016
3b3cdc4
Encode::MIME::Header: Add tests for decoding long strings
pali Oct 6, 2016
2770a0b
Encode::MIME::Header: decode: Fix decoding MIME words inside comments
pali Oct 6, 2016
c85796f
Encode::MIME::Header: Fix charset regex according to RFC 2047 grammar
pali Oct 6, 2016
03ce818
Encode::MIME::Header: Extend language regex for RFC 5646 (obsoletes R…
pali Oct 6, 2016
ae1958c
Encode::MIME::Header: Add me into AUTHORS section
pali Oct 6, 2016
dad0bc9
Encode::MIME::Header: Rewrite POD documentation
pali Oct 6, 2016
ba0f5c1
Encode::MIME::Header: Change names of variables and functions to bett…
pali Oct 11, 2016
6c2e4af
Encode::MIME::Header: encode: Do not allow to set bigger size of enco…
pali Oct 11, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 25 additions & 1 deletion Encode.pm
Expand Up @@ -15,7 +15,7 @@ use Exporter 5.57 'import';

our @EXPORT = qw(
decode decode_utf8 encode encode_utf8 str2bytes bytes2str
encodings find_encoding clone_encoding
encodings find_encoding find_mime_encoding clone_encoding
);
our @FB_FLAGS = qw(
DIE_ON_ERR WARN_ON_ERR RETURN_ON_ERR LEAVE_SRC
Expand Down Expand Up @@ -102,6 +102,8 @@ sub define_encoding {
sub getEncoding {
my ( $class, $name, $skip_external ) = @_;

defined($name) or return;

$name =~ s/\s+//g; # https://rt.cpan.org/Ticket/Display.html?id=65796

ref($name) && $name->can('renew') and return $name;
Expand Down Expand Up @@ -130,6 +132,14 @@ sub find_encoding($;$) {
return __PACKAGE__->getEncoding( $name, $skip_external );
}

sub find_mime_encoding($;$) {
my ( $mime_name, $skip_external ) = @_;
eval { require Encode::MIME::Name; };
$@ and return;
my $name = Encode::MIME::Name::get_encode_name( $mime_name );
return find_encoding( $name, $skip_external );
}

sub resolve_alias($) {
my $obj = find_encoding(shift);
defined $obj and return $obj->name;
Expand Down Expand Up @@ -577,6 +587,20 @@ name of the encoding object.

See L<Encode::Encoding> for details.

=head3 find_mime_encoding

[$obj =] find_mime_encoding(MIME_ENCODING)

Returns the I<encoding object> corresponding to I<MIME_ENCODING>. Acts
same as C<find_encoding()> but C<mime_name()> of returned object must
match to I<MIME_ENCODING>. So as opposite of C<find_encoding()>
canonical names and aliases are not used when searching for object.

find_mime_encoding("utf8"); # returns undef because "utf8" is not valid I<MIME_ENCODING>
find_mime_encoding("utf-8"); # returns encode object "utf-8-strict"
find_mime_encoding("UTF-8"); # same as "utf-8" because I<MIME_ENCODING> is case insensitive
find_mime_encoding("utf-8-strict"); returns undef because "utf-8-strict" is not valid I<MIME_ENCODING>

=head3 from_to

[$length =] from_to($octets, FROM_ENC, TO_ENC [, CHECK])
Expand Down