home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / QuotedPrint.pm < prev    next >
Encoding:
Perl POD Document  |  2000-11-04  |  2.2 KB  |  110 lines

  1. package MIME::Decoder::QuotedPrint;
  2.  
  3.  
  4. =head1 NAME
  5.  
  6. MIME::Decoder::QuotedPrint - encode/decode a "quoted-printable" stream
  7.  
  8.  
  9. =head1 SYNOPSIS
  10.  
  11. A generic decoder object; see L<MIME::Decoder> for usage.
  12.  
  13.  
  14. =head1 DESCRIPTION
  15.  
  16. A MIME::Decoder subclass for the C<"quoted-printable"> encoding.
  17. The name was chosen to jibe with the pre-existing MIME::QuotedPrint
  18. utility package, which this class actually uses to translate each line.
  19.  
  20. =over 4
  21.  
  22. =item *
  23.  
  24. The B<decoder> does a line-by-line translation from input to output.
  25.  
  26. =item *
  27.  
  28. The B<encoder> does a line-by-line translation, breaking lines
  29. so that they fall under the standard 76-character limit for this
  30. encoding.  
  31.  
  32. =back
  33.  
  34.  
  35. B<Note:> just like MIME::QuotedPrint, we currently use the 
  36. native C<"\n"> for line breaks, and not C<CRLF>.  This may
  37. need to change in future versions.
  38.  
  39.  
  40. =head1 AUTHOR
  41.  
  42. Eryq (F<eryq@zeegee.com>), ZeeGee Software Inc (F<http://www.zeegee.com>).
  43.  
  44. All rights reserved.  This program is free software; you can redistribute 
  45. it and/or modify it under the same terms as Perl itself.
  46.  
  47.  
  48. =head1 VERSION
  49.  
  50. $Revision: 5.403 $ $Date: 2000/11/04 19:54:49 $
  51.  
  52.  
  53. =cut
  54.  
  55. use vars qw(@ISA $VERSION);
  56. use MIME::Decoder;
  57. use MIME::QuotedPrint 2.03;
  58.  
  59. @ISA = qw(MIME::Decoder);
  60.  
  61. # The package version, both in 1.23 style *and* usable by MakeMaker:
  62. $VERSION = substr q$Revision: 5.403 $, 10;
  63.  
  64. #------------------------------
  65. #
  66. # encode_qp_really STRING
  67. #
  68. # Encode QP, and then follow guideline 8 from RFC 2049 (thanks to Denis 
  69. # N. Antonioli) whereby we make things a little safer for the transport
  70. # and storage of messages.  WARNING: we can only do this if the line won't
  71. # grow beyond 76 characters!
  72. #
  73. sub encode_qp_really {
  74.     my $enc = encode_qp($_[0]);
  75.     if (length($enc) < 74) {
  76.     $enc =~ s/^\.$/=2E/g;         # force encoding of /^\.$/
  77.     $enc =~ s/^From /=46rom /g;   # force encoding of /^From /
  78.     }
  79.     $enc;
  80. }
  81.  
  82. #------------------------------
  83. #
  84. # decode_it IN, OUT
  85. #
  86. sub decode_it {
  87.     my ($self, $in, $out) = @_;
  88.  
  89.     while (defined($_ = $in->getline)) {
  90.     $out->print(decode_qp($_));
  91.     }
  92.     1;
  93. }
  94.  
  95. #------------------------------
  96. #
  97. # encode_it IN, OUT
  98. #
  99. sub encode_it {
  100.     my ($self, $in, $out) = @_;
  101.  
  102.     while (defined($_ = $in->getline)) {
  103.     $out->print(encode_qp_really($_));
  104.     }
  105.     1;
  106. }
  107.  
  108. #------------------------------
  109. 1;
  110.