I duplcated the behavior on AS Perl 5.8.2 Win 2K. And a quick (very quick) look over of RFC 3548 seems to say it is broken. But I did this:

use IO::Socket; use MIME::Base64; use strict; use warnings; my $encode = encode_base64("peip:930612"); print "$encode \n"; chomp $encode; inspect($encode); my $decode = decode_base64($encode); print "\n $decode \n"; sub inspect { (my $copy = shift) =~ s/([^[:print:]])/sprintf " (0x%02x) ", ord $ + 1/ge; print $copy; }

I got this back:
cGVpcDo5MzA2MTI= cGVpcDo5MzA2MTI= peip:930612
and so worked around it.
I wonder if it is in the *NIX version of 5.8.2/5.8.3??

Update: The MIME spec allows CRLF characters in Base64:

As quoted in Above RFC: "Implementations MUST reject the encoding if it contains characters outside the base alphabet when interpreting base encoded data, unless the specification referring to this document explicitly states otherwise. Such specifications may, as MIME does, instead state that characters outside the base encoding alphabet should simply be ignored when interpreting data ("be liberal in what you accept").

Note that this means that any CRLF constitute "non alphabet characters" and are ignored. Furthermore, such specifications may consider the pad character, "=", as not part of the base alphabet until the end of the string. If more than the allowed number of pad characters are found at the end of the string, e.g., a base 64 string terminated with "===", the excess pad characters could be ignored."

MADuran
Who is in need of a spiffy sig


In reply to Re: MIME::Base64 is broken in 5.8.2? by MADuran
in thread MIME::Base64 is broken in 5.8.2? by pg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.