user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 1/3] hval: fixup bad line endings in HTML output
@ 2014-09-15 21:01 Eric Wong
  2014-09-15 21:01 ` [PATCH 2/3] index: drop signatures from nested output Eric Wong
  2014-09-15 21:01 ` [PATCH 3/3] filter: ensure CRs do not show up in lynx conversions Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2014-09-15 21:01 UTC (permalink / raw)
  To: meta; +Cc: Eric Wong

We should do this in filter, too, but sometimes we
prefer to avoid filtering the message at all.
---
 lib/PublicInbox/Hval.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/PublicInbox/Hval.pm b/lib/PublicInbox/Hval.pm
index 9be163a..68f8954 100644
--- a/lib/PublicInbox/Hval.pm
+++ b/lib/PublicInbox/Hval.pm
@@ -55,6 +55,7 @@ my %xhtml_map = (
 
 sub ascii_html {
 	my ($s) = @_;
+	$s =~ s/\r\n/\n/sg; # fixup bad line endings
 	$s =~ s/([<>&'"])/$xhtml_map{$1}/ge;
 	$enc_ascii->encode($s, Encode::HTMLCREF);
 }
-- 
EW


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] index: drop signatures from nested output
  2014-09-15 21:01 [PATCH 1/3] hval: fixup bad line endings in HTML output Eric Wong
@ 2014-09-15 21:01 ` Eric Wong
  2014-09-15 21:01 ` [PATCH 3/3] filter: ensure CRs do not show up in lynx conversions Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2014-09-15 21:01 UTC (permalink / raw)
  To: meta; +Cc: Eric Wong

We have a less-ambiguous "more..." link nowadays if somebody
wants to see the full message.
---
 lib/PublicInbox/View.pm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index ce63f7d..028c276 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -109,13 +109,13 @@ sub index_entry {
 
 		my $s = add_text_body_short($enc, $part, $part_nr, $fhref);
 
-		# keep signatures for now?  They shold usually be short,
-		# and sometimes footnotes/"P.S." appear there.
-
 		# drop the remainder of git patches, they're usually better
 		# to review when the full message is viewed
 		$s =~ s!^---\n.*\z!!ms and $more = 'more...';
 
+		# Drop signatures
+		$s =~ s/^-- \n.*\z//ms and $more = 'more...';
+
 		# kill any leading or trailing whitespace
 		$s =~ s/\A\s+//s;
 		$s =~ s/\s+\z//s;
-- 
EW


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] filter: ensure CRs do not show up in lynx conversions
  2014-09-15 21:01 [PATCH 1/3] hval: fixup bad line endings in HTML output Eric Wong
  2014-09-15 21:01 ` [PATCH 2/3] index: drop signatures from nested output Eric Wong
@ 2014-09-15 21:01 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
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	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-15 21:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-15 21:01 [PATCH 1/3] hval: fixup bad line endings in HTML output Eric Wong
2014-09-15 21:01 ` [PATCH 2/3] index: drop signatures from nested output Eric Wong
2014-09-15 21:01 ` [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).