Skip to content
Snippets Groups Projects
Commit 5716774a authored by rswindell's avatar rswindell
Browse files

Automatic UTF-8 header field detection in savemsg(): if the to, from, or

subject header fields are non-ASCII yet valid UTF-8, set the auxattr flag
indicating that the msg header is in UTF-8.
This function is used by JS MsgBase.save_msg(), so any scripts/services that
use it (e.g. nntpservice, newslink, imapservice, etc.) to save messages with
header fields that may be UTF-8 encoded will automatically benefit from this
detection. Mixing CP437 (the default) with UTF-8 encoded header fields is not
supported, so if one header field is valid UTF-8 (not plain US-ASCII), then
they had better all be either plain US-ASCII or UTF-8 or there will be
UTF-8 decoding issues when attempting to display or convert later.
parent d7920d69
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@
****************************************************************************/
#include "sbbs.h"
#include "utf8.h"
int msgbase_open(scfg_t* cfg, smb_t* smb, unsigned int subnum, int* storage, long* dupechk_hashes, uint16_t* xlat)
{
......@@ -456,6 +457,11 @@ extern "C" int DLLCALL savemsg(scfg_t* cfg, smb_t* smb, smbmsg_t* msg, client_t*
add_msg_ids(cfg, smb, msg, remsg);
if((msg->to != NULL && !str_is_ascii(msg->to) && utf8_str_is_valid(msg->to))
|| (msg->from != NULL && !str_is_ascii(msg->from) && utf8_str_is_valid(msg->from))
|| (msg->subj != NULL && !str_is_ascii(msg->subj) && utf8_str_is_valid(msg->subj)))
msg->hdr.auxattr |= MSG_HFIELDS_UTF8;
if((i=smb_addmsg(smb,msg,smb_storage_mode(cfg, smb),dupechk_hashes,xlat,(uchar*)msgbuf, /* tail: */NULL))==SMB_SUCCESS
&& msg->to!=NULL /* no recipient means no header created at this stage */) {
if(smb->subnum == INVALID_SUB) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment