12 # plain ascii should not be encoded
13 ["quoted printable" =>
16 # 8-bit chars should be encoded
17 ["v\xe5re kj\xe6re norske tegn b\xf8r \xe6res" =>
18 "v=E5re kj=E6re norske tegn b=F8r =E6res"],
20 # trailing space should be encoded
22 ["\tt\t" => "\tt=09"],
23 ["test \ntest\n\t \t \n" => "test=20=20\ntest\n=09=20=09=20\n"],
25 # "=" is special an should be decoded
27 ["\0\xff" => "=00=FF"],
29 # Very long lines should be broken (not more than 76 chars
30 ["The Quoted-Printable encoding is intended to represent data that largly consists of octets that correspond to printable characters in the ASCII character set." =>
31 "The Quoted-Printable encoding is intended to represent data that largly con=
32 sists of octets that correspond to printable characters in the ASCII charac=
36 # Long lines after short lines were broken through 2.01.
38 In America, any boy may become president and I suppose that's just one of the risks he takes. -- Adlai Stevenson" =>
40 In America, any boy may become president and I suppose that's just one of t=
41 he risks he takes. -- Adlai Stevenson"],
43 # My (roderick@argon.org) first crack at fixing that bug failed for
44 # multiple long lines.
45 ["College football is a game which would be much more interesting if the faculty played instead of the students, and even more interesting if the
46 trustees played. There would be a great increase in broken arms, legs, and necks, and simultaneously an appreciable diminution in the loss to humanity. -- H. L. Mencken" =>
47 "College football is a game which would be much more interesting if the facu=
48 lty played instead of the students, and even more interesting if the
49 trustees played. There would be a great increase in broken arms, legs, and=
50 necks, and simultaneously an appreciable diminution in the loss to humanit=
51 y. -- H. L. Mencken"],
53 # Don't break a line that's near but not over 76 chars.
54 ["$x70!23" => "$x70!23"],
55 ["$x70!234" => "$x70!234"],
56 ["$x70!2345" => "$x70!2345"],
57 ["$x70!23456" => "$x70!23456"],
58 ["$x70!23\n" => "$x70!23\n"],
59 ["$x70!234\n" => "$x70!234\n"],
60 ["$x70!2345\n" => "$x70!2345\n"],
61 ["$x70!23456\n" => "$x70!23456\n"],
63 # Not allowed to break =XX escapes using soft line break
64 ["$x70===xxxx" => "$x70=3D=\n=3D=3Dxxxx"],
65 ["$x70!===xxx" => "$x70!=3D=\n=3D=3Dxxx"],
66 ["$x70!!===xx" => "$x70!!=3D=\n=3D=3Dxx"],
67 ["$x70!!!===x" => "$x70!!!=\n=3D=3D=3Dx"],
74 $notests = @tests + 2;
75 print "1..$notests\n";
80 ($plain, $encoded) = @$_;
81 $x = encode_qp($plain);
83 print "Encode test failed\n";
85 print "Expected: '$encoded'\n";
86 print "not ok $testno\n";
89 $x = decode_qp($encoded);
91 print "Decode test failed\n";
93 print "Expected: '$plain'\n";
94 print "not ok $testno\n";
100 # Some extra testing for a case that was wrong until libwww-perl-5.09
101 print "not " unless decode_qp("foo \n\nfoo =\n\nfoo=20\n\n") eq
102 "foo\n\nfoo \nfoo \n\n";
103 $testno++; print "ok $testno\n";
105 # Same test but with "\r\n" terminated lines
106 print "not " unless decode_qp("foo \r\n\r\nfoo =\r\n\r\nfoo=20\r\n\r\n") eq
107 "foo\r\n\r\nfoo \r\nfoo \r\n\r\n";
108 $testno++; print "ok $testno\n";