Skip to content
Snippets Groups Projects
Commit e565bc12 authored by deuce's avatar deuce
Browse files

Initial support for anonymous messages... achieved by the new lib function

clean_msg_header() which sanitizes the headers as appropriate.
parent 5fbc0082
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@ load("sbbsdefs.js");
load("html_inc/template.ssjs");
load("html_inc/msgsconfig.ssjs");
/* Flags for clean_msg_headers() */
CLEAN_MSG_REPLY = (1<<0);
http_reply.header["Pragma"]="no-cache";
http_reply.header["Expires"]="0";
......@@ -121,3 +124,16 @@ function can_delete(mnum)
}
return(true);
}
function clean_msg_headers(hdr,flags)
{
if(hdr.subject=='')
hdr.subject="-- No Subject --";
if(hdr.attr&MSG_ANONYMOUS) {
if((!(flags&CLEAN_MSG_REPLY)) && user.security.level>=90)
hdr.from='Anonymous ('+hdr.from+')';
else
hdr.from="Anonymous";
}
return(hdr);
}
......@@ -29,7 +29,7 @@ else {
template.idx=msgbase.get_msg_index(false,m);
if(sub=='mail' && template.idx.to!=user.number)
error("You can only read e-mail messages addressed to yourself!");
template.hdr=msgbase.get_msg_header(false,m);
template.hdr=clean_msg_headers(msgbase.get_msg_header(false,m),0);
template.body=msgbase.get_msg_body(false,m);
msg=mime_decode(template.hdr,template.body);
......
......@@ -108,12 +108,9 @@ else {
}
for(displayed=0;displayed<max_messages && last_offset >= 0;last_offset--) {
var hdr=msgbase.get_msg_header(true,msgarray[last_offset].offset);
var hdr=clean_msg_headers(msgbase.get_msg_header(true,msgarray[last_offset].offset),0);
if(hdr==null)
continue;
msgarray[last_offset].hdr != null
if(hdr.subject=='')
hdr.subject="-- No Subject --";
template.messages[displayed.toString()]=hdr;
template.messages[displayed.toString()].attachments=count_attachments(msgarray[last_offset].hdr,msgbase.get_msg_body(true,msgarray[last_offset].offset));
template.messages[displayed.toString()].offset=msgarray[last_offset].offset;
......
......@@ -17,7 +17,7 @@ if(sub!='mail') {
if(msgbase.open!=undefined && msgbase.open()==false) {
error(msgbase.last_error);
}
hdr=msgbase.get_msg_header(false,parseInt(http_request.query.reply_to));
hdr=clean_msg_headers(msgbase.get_msg_header(false,parseInt(http_request.query.reply_to)),CLEAN_MSG_REPLY);
template.subject=hdr.subject;
if(template.subject.search(/^re:\s+/i)==-1)
template.subject='Re: '+template.subject;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment