From 27beeb0425cd92343d3d529e37f01de8982a1078 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 15 Apr 2014 06:18:43 +0000 Subject: HTML: ensure hrefs are quoted properly We may be breaking some parsers or allowing more breakage to slip through without quotes. We waste some bytes, though. --- lib/PublicInbox/Feed.pm | 6 +++--- lib/PublicInbox/View.pm | 11 ++++++----- t/view.t | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index 16b860cb..b08bd883 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -69,8 +69,8 @@ sub generate_html_index { $th->thread; my @args = ( "$title" . - '' . + '' . '
');
 	push @args, $feed_opts->{midurl};
 	dump_html_line($_, 0, \@args) for $th->rootset;
@@ -217,7 +217,7 @@ sub dump_html_line {
 		(defined($from) && length($from)) or $from = $from[0]->address;
 		$from = escapeHTML($from);
 		$subj = escapeHTML($subj);
-		$args->[0] .= "`-> $subj $from\n";
+		$args->[0] .= "`-> $subj $from\n";
 	} else {
 		$args->[0] .= "[ Message not available ]\n";
 	}
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 9237f323..7c92cbab 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -83,8 +83,8 @@ sub add_text_body_short {
 				$cur .= shift(@sum) . ' ';
 			} while (@sum && length($cur) < 68);
 			$cur=~ s/ \z/ .../;
-			"> <$cur<\/a>>";
+			"> <$cur<\/a>>";
 		} else {
 			$cur;
 		}
@@ -140,14 +140,15 @@ sub headers_to_html_header {
 	my $mid = $simple->header('Message-ID');
 	if (defined $mid) {
 		my ($html, $href) = trim_message_id($mid);
-		$rv .= "Message-ID: $html ";
-		$rv .= "(original)\n";
+		$rv .= "Message-ID: <$html> ";
+		$rv .= "(original)\n";
 	}
 
 	my $irp = $simple->header('In-Reply-To');
 	if (defined $irp) {
 		my ($html, $href) = trim_message_id($irp);
-		$rv .= "In-Reply-To: $html\n";
+		$rv .= "In-Reply-To: <";
+		$rv .= "$html>\n";
 	}
 	$rv .= "\n";
 
diff --git a/t/view.t b/t/view.t
index ad79c413..ef1b74c9 100644
--- a/t/view.t
+++ b/t/view.t
@@ -33,7 +33,7 @@ EOF
 	my $html = PublicInbox::View->as_html($s);
 
 	# ghetto
-	like($html, qr/]+>> Long and wordy/,
@@ -44,7 +44,7 @@ EOF
 	my $short = PublicInbox::View->as_html($s, $pfx);
 	like($short, qr/\n> keep this inline/,
 		"short quoted text is inline");
-	like($short, qr/]+>Long and wordy/,
+	like($short, qr/