added: Q encoding in misc: QEncode()
for mails headers encoding git-svn-id: svn://ttmath.org/publicrep/winix/trunk@711 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
3071df227a
commit
00521c490e
|
@ -952,3 +952,62 @@ static std::string ain;
|
||||||
UrlEncode(ain, out, clear_out);
|
UrlEncode(ain, out, clear_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void QEncodeAddChar(wchar_t c, std::string & out)
|
||||||
|
{
|
||||||
|
if( (c>='A' && c<='Z') ||
|
||||||
|
(c>='a' && c<='z') ||
|
||||||
|
(c>='0' && c<='9') )
|
||||||
|
{
|
||||||
|
out += char(c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char buf1[10];
|
||||||
|
char buf2[10];
|
||||||
|
|
||||||
|
size_t len1 = sizeof(buf1) / sizeof(char);
|
||||||
|
size_t len2 = sizeof(buf2) / sizeof(char);
|
||||||
|
size_t len = Ezc::IntToUTF8(int(c), buf1, len1);
|
||||||
|
|
||||||
|
for(size_t i=0 ; i<len ; ++i)
|
||||||
|
{
|
||||||
|
// make sure that it produces *capital* letters (ABC...)
|
||||||
|
Toa((unsigned long)(unsigned char)buf1[i], buf2, len2, 16);
|
||||||
|
out += '=';
|
||||||
|
out += buf2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
this encoding is used in mails headers
|
||||||
|
encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
|
||||||
|
http://www.faqs.org/rfcs/rfc1522.html
|
||||||
|
|
||||||
|
we have:
|
||||||
|
charset = UTF-8
|
||||||
|
encoding = Q
|
||||||
|
|
||||||
|
current limitation:
|
||||||
|
we do not support checking the maximum length:
|
||||||
|
"An encoded-word may not be more than 75 characters long, including
|
||||||
|
charset, encoding, encoded-text, and delimiters."
|
||||||
|
*/
|
||||||
|
void QEncode(const std::wstring & in, std::string & out, bool clear)
|
||||||
|
{
|
||||||
|
if( clear )
|
||||||
|
out.clear();
|
||||||
|
|
||||||
|
out += "=?UTF-8?Q?";
|
||||||
|
|
||||||
|
for(size_t i=0 ; i<in.size() ; ++i)
|
||||||
|
QEncodeAddChar(in[i], out);
|
||||||
|
|
||||||
|
out += "?=";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -426,5 +426,6 @@ tm Time(time_t par);
|
||||||
void UrlEncode(const std::string & in, std::string & out, bool clear_out = true);
|
void UrlEncode(const std::string & in, std::string & out, bool clear_out = true);
|
||||||
void UrlEncode(const std::wstring & in, std::string & out, bool clear_out = true);
|
void UrlEncode(const std::wstring & in, std::string & out, bool clear_out = true);
|
||||||
|
|
||||||
|
void QEncode(const std::wstring & in, std::string & out, bool clear = true);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -110,4 +110,4 @@ templatesnotify.o: ../templates/indexpatterns.h ../templates/localefilter.h
|
||||||
templatesnotify.o: ../templates/locale.h ../templates/htmltextstream.h
|
templatesnotify.o: ../templates/locale.h ../templates/htmltextstream.h
|
||||||
templatesnotify.o: ../core/sessionmanager.h ../core/sessioncontainer.h
|
templatesnotify.o: ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||||
templatesnotify.o: ../core/session.h ../core/user.h ../core/cur.h
|
templatesnotify.o: ../core/session.h ../core/user.h ../core/cur.h
|
||||||
templatesnotify.o: ../core/lastcontainer.h
|
templatesnotify.o: ../core/lastcontainer.h ../core/misc.h
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "templatesnotify.h"
|
#include "templatesnotify.h"
|
||||||
#include "core/plugin.h"
|
#include "core/plugin.h"
|
||||||
|
#include "core/misc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +23,8 @@ Ezc::Functions<NotifyStream> ezc_functions;
|
||||||
NotifyUserMsg notify_user_msg;
|
NotifyUserMsg notify_user_msg;
|
||||||
NotifyMsg notify_msg;
|
NotifyMsg notify_msg;
|
||||||
|
|
||||||
|
// name in qencoding
|
||||||
|
static std::string name_q;
|
||||||
|
|
||||||
|
|
||||||
void notify_file_added(Info & i)
|
void notify_file_added(Info & i)
|
||||||
|
@ -71,19 +73,17 @@ void notify_thread_post_changed(Info & i)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void notify_to(Info & i)
|
void notify_to_email(Info & i)
|
||||||
{
|
{
|
||||||
i.out << notify_user_msg.email;
|
i.out << notify_user_msg.email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void notify_to_name(Info & i)
|
||||||
/*
|
|
||||||
void notify_doc_base_url(Info & i)
|
|
||||||
{
|
{
|
||||||
i.out << notify_user_msg.doc_base_url;
|
QEncode(notify_user_msg.name, name_q);
|
||||||
|
i.out << name_q;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
void notify_item_link(Info & i)
|
void notify_item_link(Info & i)
|
||||||
|
@ -98,6 +98,8 @@ void notify_dir_link(Info & i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CreateFunctions()
|
void CreateFunctions()
|
||||||
{
|
{
|
||||||
ezc_functions.Clear();
|
ezc_functions.Clear();
|
||||||
|
@ -111,8 +113,8 @@ void CreateFunctions()
|
||||||
ezc_functions.Insert("notify_thread_replayed", notify_thread_replayed);
|
ezc_functions.Insert("notify_thread_replayed", notify_thread_replayed);
|
||||||
ezc_functions.Insert("notify_thread_post_changed", notify_thread_post_changed);
|
ezc_functions.Insert("notify_thread_post_changed", notify_thread_post_changed);
|
||||||
|
|
||||||
ezc_functions.Insert("notify_to", notify_to);
|
ezc_functions.Insert("notify_to_email", notify_to_email);
|
||||||
//ezc_functions.Insert("notify_doc_base_url", notify_doc_base_url);
|
ezc_functions.Insert("notify_to_name", notify_to_name);
|
||||||
ezc_functions.Insert("notify_item_link", notify_item_link);
|
ezc_functions.Insert("notify_item_link", notify_item_link);
|
||||||
ezc_functions.Insert("notify_dir_link", notify_dir_link);
|
ezc_functions.Insert("notify_dir_link", notify_dir_link);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Subject: [if notify_file_added]{notify_new}[else]{notify_change}[end]\n
|
Subject: [if notify_file_added]{notify_new}[else]{notify_change}[end]\n
|
||||||
From: {notify_from}\n
|
From: {notify_from}\n
|
||||||
To: [notify_to]\n
|
To: [notify_to_name] <[notify_to_email]>\n
|
||||||
Content-Type: {notify_content_type}
|
Content-Type: {notify_content_type}
|
||||||
\n\n
|
\n\n
|
||||||
{notify_header}
|
{notify_header}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Subject: [if notify_thread_added]{notify_new}[else]{notify_change}[end]\n
|
Subject: [if notify_thread_added]{notify_new}[else]{notify_change}[end]\n
|
||||||
From: {notify_from}\n
|
From: {notify_from}\n
|
||||||
To: [notify_to]\n
|
To: [notify_to_name] <[notify_to_email]>\n
|
||||||
Content-Type: {notify_content_type}
|
Content-Type: {notify_content_type}
|
||||||
\n\n
|
\n\n
|
||||||
{notify_header}
|
{notify_header}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Subject: {notify_new}\n
|
Subject: {notify_new}\n
|
||||||
From: {notify_from}\n
|
From: {notify_from}\n
|
||||||
To: [notify_to]\n
|
To: [notify_to_name] <[notify_to_email]>\n
|
||||||
Content-Type: {notify_content_type}
|
Content-Type: {notify_content_type}
|
||||||
\n\n
|
\n\n
|
||||||
{notify_header}
|
{notify_header}
|
||||||
|
|
Loading…
Reference in New Issue