From: Eric Wong Date: Mon, 15 Sep 2014 20:58:41 +0000 (+0000) Subject: filter: ensure CRs do not show up in lynx conversions X-Git-Tag: v1.0.0~1111 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=1a4da197b5390141ae338d80199112b256b140ba;hp=a4cea21b8bde2897786a8fab4b33b669b935011c;p=public-inbox.git filter: ensure CRs do not show up in lynx conversions Unix line endings are LF-only, so do not introduce or preserve CRLF line endings when reading from lynx. --- diff --git a/lib/PublicInbox/Filter.pm b/lib/PublicInbox/Filter.pm index e784cded..929a8ffc 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 e4f6a2b0..7a4bdb19 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"); }