user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 2/8] view: single id="t" for multi-Subject messages
Date: Sat, 15 Feb 2020 09:46:34 +0000	[thread overview]
Message-ID: <20200215094640.19425-3-e@yhbt.net> (raw)
In-Reply-To: <20200215094640.19425-1-e@yhbt.net>

While multi-Subject messages are unfortunate, try not to
generate confusing/invalid HTML with multiple elements
having the same HTML id attribute.
---
 lib/PublicInbox/View.pm | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index dcaee1ae..45c191db 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -651,16 +651,15 @@ sub _msg_page_prepare_obuf {
 	}
 	my @subj = $hdr->header('Subject');
 	if (@subj) {
-		for my $v (@subj) {
+		my $v = ascii_html(shift @subj);
+		obfuscate_addrs($obfs_ibx, $v) if $obfs_ibx;
+		$rv .= 'Subject: ';
+		$rv .= $over ? qq(<a\nhref="#r"\nid=t>$v</a>\n) : "$v\n";
+		$title[0] = $v;
+		for $v (@subj) { # multi-Subject message :<
 			$v = ascii_html($v);
 			obfuscate_addrs($obfs_ibx, $v) if $obfs_ibx;
-			$rv .= 'Subject: ';
-			if ($over) {
-				$rv .= qq(<a\nhref="#r"\nid=t>$v</a>\n);
-			} else {
-				$rv .= "$v\n";
-			}
-			$title[0] //= $v;
+			$rv .= "Subject: $v\n";
 		}
 	} else { # dummy anchor for thread skeleton at bottom of page
 		$rv .= qq(<a\nhref="#r"\nid=t></a>) if $over;

  parent reply	other threads:[~2020-02-15  9:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-15  9:46 [PATCH 0/8] some view cleanups and minor bugfixes Eric Wong
2020-02-15  9:46 ` [PATCH 1/8] view: remove mhref arg from multipart_text_as_html Eric Wong
2020-02-15  9:46 ` Eric Wong [this message]
2020-02-15  9:46 ` [PATCH 3/8] view: dump_topics: better naming of top Subject Eric Wong
2020-02-15  9:46 ` [PATCH 4/8] view: cleanup topic accumulation and dumping Eric Wong
2020-02-15  9:46 ` [PATCH 5/8] view,searchview: avoid smsg method calls when using SQLite/Xapian Eric Wong
2020-02-15  9:46 ` [PATCH 6/8] view: escape Subject HTML directly Eric Wong
2020-02-15  9:46 ` [PATCH 7/8] view: escape ampersand in Message-IDs Eric Wong
2020-02-15  9:46 ` [PATCH 8/8] view: remove last Hval->new caller Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200215094640.19425-3-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).