From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] searchmsg: ensure long subject lines are not broken
Date: Sat, 30 Apr 2016 02:05:25 +0000 [thread overview]
Message-ID: <20160430020525.11608-1-e@80x24.org> (raw)
Noticed when using a long URL in the subject.
---
lib/PublicInbox/SearchMsg.pm | 7 ++-----
t/search.t | 25 ++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm
index a089915..1244aee 100644
--- a/lib/PublicInbox/SearchMsg.pm
+++ b/lib/PublicInbox/SearchMsg.pm
@@ -148,12 +148,9 @@ sub ensure_metadata {
sub mini_mime {
my ($self) = @_;
$self->ensure_metadata;
- my @hs = (
+ my @h = (
'Subject' => $self->subject,
'X-PI-From' => $self->from_name,
- );
-
- my @h = (
# prevent Email::Simple::Creator from running,
# this header is useless for threading as we use X-PI-TS
# for sorting and display:
@@ -164,7 +161,7 @@ sub mini_mime {
if (my $refs = $self->{references}) {
push @h, References => $refs;
}
- my $mime = Email::MIME->create(header_str => \@hs, header => \@h);
+ my $mime = Email::MIME->create(header => \@h);
my $h = $mime->header_obj;
# set these headers manually since Encode::encode('MIME-Q', ...)
diff --git a/t/search.t b/t/search.t
index bbf1a89..d5f9d95 100644
--- a/t/search.t
+++ b/t/search.t
@@ -274,10 +274,11 @@ sub filter_mids {
# circular references
{
+ my $s = 'foo://'. ('Circle' x 15).'/foo';
my $doc_id = $rw->add_message(Email::MIME->create(
+ header => [ Subject => $s ],
header_str => [
Date => 'Sat, 02 Oct 2010 00:00:01 +0000',
- Subject => 'Circle',
'Message-ID' => '<circle@a>',
'References' => '<circle@a>',
'In-Reply-To' => '<circle@a>',
@@ -289,6 +290,28 @@ sub filter_mids {
my $smsg = $rw->lookup_message('circle@a');
$smsg->ensure_metadata;
is($smsg->references, '', "no references created");
+ my $msg = PublicInbox::SearchMsg->load_doc($smsg->{doc});
+ is($s, $msg->mini_mime->header('Subject'), 'long subject not rewritten');
+}
+
+{
+ my $str = eval {
+ my $mbox = 't/utf8.mbox';
+ open(my $fh, '<', $mbox) or die "failed to open mbox: $mbox\n";
+ local $/;
+ <$fh>
+ };
+ $str =~ s/\AFrom [^\n]+\n//s;
+ my $mime = Email::MIME->new($str);
+ my $doc_id = $rw->add_message($mime);
+ ok($doc_id > 0, 'message indexed doc_id with UTF-8');
+ my $smsg = $rw->lookup_message('testmessage@example.com');
+ my $msg = PublicInbox::SearchMsg->load_doc($smsg->{doc});
+
+ # mini_mime technically not valid (I think),
+ # but good enough for displaying HTML:
+ is($mime->header('Subject'), $msg->mini_mime->header('Subject'),
+ 'UTF-8 subject preserved');
}
done_testing();
--
EW
reply other threads:[~2016-04-30 2:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20160430020525.11608-1-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).