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

If there are non US-ASCII characters in the headers, first check if they're

UTF-8 and if so, convert using uft8_ascii(), otherwise, just replace every
non-US-ASCII byte with a question mark.

RFC*822 does not allow anything but US-ASCII in headers.
parent 25abf85d
No related branches found
No related tags found
No related merge requests found
const RFC822HEADER = 0xb0; // from smbdefs.h const RFC822HEADER = 0xb0; // from smbdefs.h
require("utf8_ascii.js", 'utf8_ascii');
MsgBase.HeaderPrototype.get_rfc822_header=function(force_update) MsgBase.HeaderPrototype.get_rfc822_header=function(force_update)
{ {
...@@ -83,6 +84,17 @@ MsgBase.HeaderPrototype.get_rfc822_header=function(force_update) ...@@ -83,6 +84,17 @@ MsgBase.HeaderPrototype.get_rfc822_header=function(force_update)
// Unwrap headers // Unwrap headers
this.rfc822=this.rfc822.replace(/\s*\r\n\s+/g, " "); this.rfc822=this.rfc822.replace(/\s*\r\n\s+/g, " ");
this.rfc822 += "\r\n"; this.rfc822 += "\r\n";
// Illegal characters in header?
if (this.rfc822.search(/[^\x01-\x7f]/) != -1) {
/* Is it UTF-8? */
if (this.rfc822.replace(/[\xc0-\xfd][\x80-\xbf]+/g,'').search(/[^\x01-\x7f]/) == -1) {
this.rfc822 = utf8_ascii(this.rfc822);
}
else {
// If not, just strip them all...
this.rfc822 = this.rfc822.replace(/[^\x01-\x7f]/g, '?');
}
}
} }
return this.rfc822; return this.rfc822;
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment