* [PATCH 3/3] filter: ensure CRs do not show up in lynx conversions
@ 2014-09-15 21:01 7% ` Eric Wong
0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2014-09-15 21:01 UTC (permalink / raw)
To: meta; +Cc: Eric Wong
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 => "<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");
}
--
EW
^ permalink raw reply related [relevance 7%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2014-09-15 21:01 [PATCH 1/3] hval: fixup bad line endings in HTML output Eric Wong
2014-09-15 21:01 7% ` [PATCH 3/3] filter: ensure CRs do not show up in lynx conversions Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).