From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.4 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C2D071F498; Mon, 15 Sep 2014 21:01:50 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Cc: Eric Wong Subject: [PATCH 3/3] filter: ensure CRs do not show up in lynx conversions Date: Mon, 15 Sep 2014 21:01:38 +0000 Message-Id: <1410814898-8628-3-git-send-email-e@80x24.org> X-Mailer: git-send-email 2.1.0.243.g30d45f7 In-Reply-To: <1410814898-8628-1-git-send-email-e@80x24.org> References: <1410814898-8628-1-git-send-email-e@80x24.org> List-Id: Unix line endings are LF-only, so do not introduce or preserve CRLF line endings when reading from lynx. --- lib/PublicInbox/Filter.pm | 1 + t/filter.t | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/Filter.pm b/lib/PublicInbox/Filter.pm index e784cde..929a8ff 100644 --- a/lib/PublicInbox/Filter.pm +++ b/lib/PublicInbox/Filter.pm @@ -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: diff --git a/t/filter.t b/t/filter.t index e4f6a2b..7a4bdb1 100644 --- a/t/filter.t +++ b/t/filter.t @@ -85,13 +85,14 @@ sub count_body_parts { 'Content-Type' => 'text/html', Subject => 'HTML only badness', ], - body => "bad body\n", + body => "bad body\r\n\n", ); is(1, PublicInbox::Filter->run($s), "run was a success"); unlike($s->as_string, qr//, "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"); } -- EW