]> Sergey Matveev's repositories - public-inbox.git/commitdiff
filter: ensure CRs do not show up in lynx conversions
authorEric Wong <e@80x24.org>
Mon, 15 Sep 2014 20:58:41 +0000 (20:58 +0000)
committerEric Wong <e@80x24.org>
Mon, 15 Sep 2014 20:58:41 +0000 (20:58 +0000)
Unix line endings are LF-only, so do not introduce or preserve
CRLF line endings when reading from lynx.

lib/PublicInbox/Filter.pm
t/filter.t

index e784cded644139160d84b4205cb5f6ffbc275923..929a8ffc5af34acf77a434e8dab249578d96b03f 100644 (file)
@@ -97,6 +97,7 @@ sub dump_html {
                push @cmd, "-assume_charset=$charset";
        }
        if (IPC::Run::run(\@cmd, $body, \$out, \$err)) {
+               $out =~ s/\r\n/\n/sg;
                $$body = $out;
        } else {
                # give them an ugly version:
index e4f6a2b09ada860fff07b12ed4d8da292610c56d..7a4bdb191abad34e86c6d816228fed28c19fad1e 100644 (file)
@@ -85,13 +85,14 @@ sub count_body_parts {
                        'Content-Type' => 'text/html',
                        Subject => 'HTML only badness',
                ],
-               body => "<html><body>bad body</body></html>\n",
+               body => "<html><body>bad body\r\n</body></html>\n",
        );
        is(1, PublicInbox::Filter->run($s), "run was a success");
        unlike($s->as_string, qr/<html>/, "HTML removed");
        is("text/plain", $s->header("Content-Type"),
                "content-type changed");
        like($s->body, qr/\A\s*bad body\s*\z/, "body");
+       unlike($s->body, qr/\r/, "body has no cr");
        like($s->header("X-Content-Filtered-By"),
                qr/PublicInbox::Filter/, "XCFB header added");
 }