Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the IMAP-BodyStructure CPAN distribution.

Report information
The Basics
Id: 99352
Status: patched
Priority: 0/
Queue: IMAP-BodyStructure

People
Owner: KAPPA [...] cpan.org
Requestors: jonas [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.01
Fixed in: (no value)



Subject: Handle body-fld-lang from rfc3501
Parsing fails on body-fld-lang, that can have the form ("en-US") in addition to "en-US" and is thus not simply an nstring. Patch attached.
Subject: BodyStructure.pm.diff
--- BodyStructure.pm.orig 2014-10-07 16:03:21.195801873 +0200 +++ BodyStructure.pm 2014-10-07 18:11:46.535800953 +0200 @@ -61,6 +61,7 @@ sub _get_npairs(\$); sub _get_ndisp(\$); sub _get_nstring(\$); +sub _get_body_fld_lang(\$); =head2 METHODS @@ -363,7 +364,7 @@ $bs->{type} .= lc(_get_nstring($$str)); $bs->{params} = _get_npairs($$str); $bs->{disp} = _get_ndisp($$str); - $bs->{lang} = _get_nstring($$str); + $bs->{lang} = _get_body_fld_lang($$str); $bs->{loc} = _get_nstring($$str); } else { $bs->{type} = lc (_get_nstring($$str) . '/' . _get_nstring($$str)); @@ -387,7 +388,7 @@ $bs->{md5} = _get_nstring($$str); $bs->{disp} = _get_ndisp($$str); - $bs->{lang} = _get_nstring($$str); + $bs->{lang} = _get_body_fld_lang($$str); $bs->{loc} = _get_nstring($$str); } @@ -472,6 +471,32 @@ return 0; } +sub _get_body_fld_lang(\$) { + my $str = $_[0]; + + # body-fld-lang = nstring / "(" string *(SP string) ")" + + if ($$str =~ m/\G\s*\(/gc) { + my @a; + while ('fareva') { + my $data = _get_nstring($$str); + $data or last; + + push @a, $data; + } + + $$str =~ m/\G\s*\)/gc; + return \@a; + } + + if ( my $data = _get_nstring($$str) ) + { + return [ $data ]; + } + + return []; +} + sub _unescape { my $str = shift;
07 Eki 2014 Sal, 12:37:23 tarihinde, jonas@cpan.org yazdı: Show quoted text
> Parsing fails on body-fld-lang, that can have the form ("en-US") in > addition to "en-US" and is thus not simply an nstring. > > Patch attached.
Thanks, included in 1.03 which I have just uploaded.