Do not strip newlines from email bodies

This commit is contained in:
dongresource 2020-11-29 21:31:54 +01:00
parent 1d7f8bd133
commit 858fbf40be
3 changed files with 7 additions and 3 deletions

View File

@ -673,7 +673,7 @@ void BuddyManager::emailSend(CNSocket* sock, CNPacketData* data) {
U16toU8(plr->PCStyle.szFirstName), // SenderFirstName U16toU8(plr->PCStyle.szFirstName), // SenderFirstName
U16toU8(plr->PCStyle.szLastName), // SenderLastName U16toU8(plr->PCStyle.szLastName), // SenderLastName
ChatManager::sanitizeText(U16toU8(pkt->szSubject)), // SubjectLine ChatManager::sanitizeText(U16toU8(pkt->szSubject)), // SubjectLine
ChatManager::sanitizeText(U16toU8(pkt->szContent)), // MsgBody ChatManager::sanitizeText(U16toU8(pkt->szContent), true), // MsgBody
pkt->iCash, // Taros pkt->iCash, // Taros
(uint64_t)getTimestamp(), // SendTime (uint64_t)getTimestamp(), // SendTime
0 // DeleteTime (unimplemented) 0 // DeleteTime (unimplemented)

View File

@ -850,7 +850,7 @@ void ChatManager::announcementHandler(CNSocket* sock, CNPacketData* data) {
} }
// we only allow plain ascii, at least for now // we only allow plain ascii, at least for now
std::string ChatManager::sanitizeText(std::string text) { std::string ChatManager::sanitizeText(std::string text, bool allowNewlines) {
int i; int i;
char buf[128]; char buf[128];
@ -858,6 +858,10 @@ std::string ChatManager::sanitizeText(std::string text) {
for (char c : text) { for (char c : text) {
if (i >= 127) if (i >= 127)
break; break;
if (!allowNewlines && c == '\n')
continue;
if (c >= ' ' && c <= '~') if (c >= ' ' && c <= '~')
buf[i++] = c; buf[i++] = c;
} }

View File

@ -29,5 +29,5 @@ namespace ChatManager {
void sendServerMessage(CNSocket* sock, std::string msg); // uses MOTD void sendServerMessage(CNSocket* sock, std::string msg); // uses MOTD
void announcementHandler(CNSocket* sock, CNPacketData* data); void announcementHandler(CNSocket* sock, CNPacketData* data);
std::string sanitizeText(std::string text); std::string sanitizeText(std::string text, bool allowNewlines=false);
} }