user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 3/4] avoid using header_raw for Message-ID retrieval
Date: Thu, 20 Aug 2015 10:20:28 +0000	[thread overview]
Message-ID: <1440066029-7400-3-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1440066029-7400-1-git-send-email-e@80x24.org>

This is for consistency with ssoma.  I doubt it makes
a difference in practice, but in case somebody decides
any of the Message-ID-containing headers should have
strange characters, we'll decode and attempt to thread
them.  This isn't an attack vector, just a way to
make messages thread improperly which is pointless...
---
 lib/PublicInbox/Feed.pm   |  4 ++--
 lib/PublicInbox/Search.pm |  8 ++++----
 lib/PublicInbox/View.pm   | 14 +++++++-------
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 2e352cb..bbf5061 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -254,7 +254,7 @@ sub add_to_feed {
 	my $fullurl = $feed_opts->{fullurl} || 'http://example.com/f/';
 
 	my $header_obj = $mime->header_obj;
-	my $mid = $header_obj->header_raw('Message-ID');
+	my $mid = $header_obj->header('Message-ID');
 	defined $mid or return 0;
 	$mid = PublicInbox::Hval->new_msgid($mid);
 	my $href = $mid->as_href . '.html';
@@ -318,7 +318,7 @@ sub add_topic {
 			my $mime = do_cat_mail($git, $path) or return 0;
 			$header_obj = $mime->header_obj;
 		}
-		my $mid = $header_obj->header_raw('Message-ID');
+		my $mid = $header_obj->header('Message-ID');
 		$mid = mid_compressed(mid_clean($mid));
 		$u = $enc_utf8->decode($u);
 		push @$order, [ $mid, $ts, $u, $subj ];
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index d9e5fd1..2c66e55 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -84,7 +84,7 @@ sub add_message {
 	my $db = $self->{xdb};
 
 	my $doc_id;
-	my $mid_orig = mid_clean($mime->header_obj->header_raw('Message-ID'));
+	my $mid_orig = mid_clean($mime->header_obj->header('Message-ID'));
 	my $mid = mid_compressed($mid_orig);
 	my $was_ghost = 0;
 	my $ct_msg = $mime->header('Content-Type') || 'text/plain';
@@ -348,9 +348,9 @@ sub link_message_to_parents {
 	my $doc = $smsg->{doc};
 	my $mid = mid_compressed($smsg->mid);
 	my $mime = $smsg->mime;
-	my $refs = $mime->header_obj->header_raw('References');
+	my $refs = $mime->header_obj->header('References');
 	my @refs = $refs ? ($refs =~ /<([^>]+)>/g) : ();
-	my $irt = $mime->header_obj->header_raw('In-Reply-To');
+	my $irt = $mime->header_obj->header('In-Reply-To');
 	if ($irt) {
 		if ($irt =~ /<([^>]+)>/) {
 			$irt = $1;
@@ -529,7 +529,7 @@ sub index_blob {
 sub unindex_blob {
 	my ($self, $git, $blob) = @_;
 	my $mime = do_cat_mail($git, $blob) or return;
-	my $mid = $mime->header_obj->header_raw('Message-ID');
+	my $mid = $mime->header_obj->header('Message-ID');
 	eval { $self->remove_message($mid) } if defined $mid;
 	warn "W: unindex_blob $blob: $@\n" if $@;
 }
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index fe701b1..fb000f2 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -57,7 +57,7 @@ sub index_entry {
 	my $subj = $mime->header('Subject');
 	my $header_obj = $mime->header_obj;
 
-	my $mid_raw = $header_obj->header_raw('Message-ID');
+	my $mid_raw = $header_obj->header('Message-ID');
 	my $id = anchor_for($mid_raw);
 	$seen->{$id} = "#$id"; # save the anchor for later
 
@@ -73,7 +73,7 @@ sub index_entry {
 	my $more = 'permalink';
 	my $path = $root_anchor ? '../' : '';
 	my $href = $mid->as_href;
-	my $irt = $header_obj->header_raw('In-Reply-To');
+	my $irt = $header_obj->header('In-Reply-To');
 	my ($anchor_idx, $anchor, $t_anchor);
 	if (defined $irt) {
 		$anchor_idx = anchor_for($irt);
@@ -361,7 +361,7 @@ sub headers_to_html_header {
 	my $rv = "";
 	my @title;
 	my $header_obj = $mime->header_obj;
-	my $mid = $header_obj->header_raw('Message-ID');
+	my $mid = $header_obj->header('Message-ID');
 	$mid = PublicInbox::Hval->new_msgid($mid);
 	my $mid_href = $mid->as_href;
 	foreach my $h (qw(From To Cc Subject Date)) {
@@ -388,7 +388,7 @@ sub headers_to_html_header {
 	$mid_href = "../m/$mid_href" unless $full_pfx;
 	$rv .= "(<a\nhref=\"$mid_href.txt\">raw</a>)\n";
 
-	my $irt = $header_obj->header_raw('In-Reply-To');
+	my $irt = $header_obj->header('In-Reply-To');
 	if (defined $irt) {
 		my $v = PublicInbox::Hval->new_msgid($irt);
 		my $html = $v->as_html;
@@ -397,7 +397,7 @@ sub headers_to_html_header {
 		$rv .= "<a\nhref=\"$href.html\">$html</a>&gt;\n";
 	}
 
-	my $refs = $header_obj->header_raw('References');
+	my $refs = $header_obj->header('References');
 	if ($refs) {
 		# avoid redundant URLs wasting bandwidth
 		my %seen;
@@ -441,7 +441,7 @@ sub html_footer {
 
 	my $subj = $mime->header('Subject') || '';
 	$subj = "Re: $subj" unless $subj =~ /\bRe:/;
-	my $mid = $mime->header_obj->header_raw('Message-ID');
+	my $mid = $mime->header_obj->header('Message-ID');
 	my $irt = uri_escape_utf8($mid);
 	delete $cc{$to};
 	$to = uri_escape_utf8($to);
@@ -452,7 +452,7 @@ sub html_footer {
 
 	my $idx = $standalone ? " <a\nhref=\"../\">index</a>" : '';
 	if ($idx && $srch) {
-		$irt = $mime->header_obj->header_raw('In-Reply-To') || '';
+		$irt = $mime->header_obj->header('In-Reply-To') || '';
 		$mid = mid_compressed(mid_clean($mid));
 		my $t_anchor = length $irt ? T_ANCHOR : '';
 		$idx = " <a\nhref=\"../t/$mid.html$t_anchor\">".
-- 
EW


  parent reply	other threads:[~2015-08-20 10:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20 10:20 [PATCH 1/4] dead code cleanup Eric Wong
2015-08-20 10:20 ` [PATCH 2/4] view: simplify message threading dumpers Eric Wong
2015-08-20 10:20 ` Eric Wong [this message]
2015-08-20 10:20 ` [PATCH 4/4] search: preserve References: order in document data 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: https://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=1440066029-7400-3-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --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).