Skip to content
Snippets Groups Projects
Commit 76fbfb15 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Use original RFC822-formatted subject, if available (e.g. recv'd via SMTP)

This solves issue #817 for TLDR messages imported into DOVE-Net Tech Talk,
because those messages are imported via SMTP originally and thus have the
original (MIME/Q-encoded subject) in the message header (as RFC822SUBJECT).

For other messages with UTF-8 characters in their header fields (e.g. subject),
we'll need a different solution (Q-encode header fields that contain
non-ASCII chars on the fly), and then this solution could maybe be reverted.
parent 6224ce64
No related branches found
No related tags found
No related merge requests found
Pipeline #7109 passed
......@@ -4,11 +4,21 @@
require("mailutil.js", 'mail_get_name');
require("smbdefs.js", 'RFC822HEADER');
function get_news_subject(hdr)
{
if(hdr.field_list !== undefined)
for(var i in hdr.field_list) {
if(hdr.field_list[i].type == RFC822SUBJECT)
return hdr.field_list[i].data;
}
return hdr.subject;
}
function write_news_header(hdr,writeln)
{
/* Required header fields */
writeln("To: " + hdr.to);
writeln("Subject: " + hdr.subject);
writeln("Subject: " + get_news_subject(hdr));
writeln("Message-ID: " + hdr.id);
writeln("Date: " + hdr.date);
......@@ -48,7 +58,7 @@ function write_news_header(hdr,writeln)
var content_type;
if(hdr.field_list!=undefined) {
for(i in hdr.field_list) {
for(var i in hdr.field_list) {
if(hdr.field_list[i].type==RFC822HEADER) {
if(hdr.field_list[i].data.toLowerCase().indexOf("content-type:")==0)
content_type = hdr.field_list[i].data;
......
......@@ -561,7 +561,7 @@ while(client.socket.is_connected && !quit) {
continue;
writeln(format("%u\t%s\t%s\t%s\t%s\t%s\t%u\t%u\tXref:%s"
,i
,hdr.subject
,get_news_subject(hdr)
,hdr.from
,hdr.date
,hdr.id // message-id
......@@ -615,7 +615,7 @@ while(client.socket.is_connected && !quit) {
field=hdr.to;
break;
case "subject":
field=hdr.subject;
field=get_news_subject(hdr);
break;
case "from":
field=hdr.from;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment