* Now sanitizes the white space in the header fields before adding them to the
message (ie. multiple spaces are compressed to a single one, tabs and other white space is replaced with a space). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42810 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ba91e5bbcd
commit
49774900fb
@ -8,8 +8,9 @@
|
|||||||
|
|
||||||
#include "HaikuMailFormatFilter.h"
|
#include "HaikuMailFormatFilter.h"
|
||||||
|
|
||||||
#include <Directory.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <Directory.h>
|
||||||
#include <E-mail.h>
|
#include <E-mail.h>
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
|
|
||||||
@ -47,6 +48,34 @@ static const mail_header_field gDefaultFields[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Replaces tabs and other white space with spaces, compresses spaces.
|
||||||
|
void
|
||||||
|
sanitize_white_space(BString& string)
|
||||||
|
{
|
||||||
|
char* buffer = string.LockBuffer(string.Length() + 1);
|
||||||
|
if (buffer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int32 count = string.Length();
|
||||||
|
int32 spaces = 0;
|
||||||
|
for (int32 i = 0; buffer[i] != '\0'; i++, count--) {
|
||||||
|
if (isspace(buffer[i])) {
|
||||||
|
buffer[i] = ' ';
|
||||||
|
spaces++;
|
||||||
|
} else {
|
||||||
|
if (spaces > 1)
|
||||||
|
memmove(buffer + i + 1 - spaces, buffer + i, count + 1);
|
||||||
|
spaces = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string.UnlockBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
HaikuMailFormatFilter::HaikuMailFormatFilter(MailProtocol& protocol,
|
HaikuMailFormatFilter::HaikuMailFormatFilter(MailProtocol& protocol,
|
||||||
BMailAccountSettings* settings)
|
BMailAccountSettings* settings)
|
||||||
:
|
:
|
||||||
@ -86,6 +115,7 @@ HaikuMailFormatFilter::HeaderFetched(const entry_ref& ref, BFile* file)
|
|||||||
|
|
||||||
switch (gDefaultFields[i].attr_type){
|
switch (gDefaultFields[i].attr_type){
|
||||||
case B_STRING_TYPE:
|
case B_STRING_TYPE:
|
||||||
|
sanitize_white_space(target);
|
||||||
attributes.AddString(gDefaultFields[i].attr_name, target);
|
attributes.AddString(gDefaultFields[i].attr_name, target);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user