зеркало из https://github.com/mozilla/gecko-dev.git
Moving Nova bug fixes to Zulu.
327870 (quoted-printable) 328185 (content-dispostion and DTSTART in REPLY)
This commit is contained in:
Родитель
9e07867ae9
Коммит
29e38c559b
|
@ -110,6 +110,7 @@ public:
|
|||
|
||||
static t_bool isHex(t_int8 aToken);
|
||||
static t_int8 convertHex(char fToken, char sToken);
|
||||
static UnicodeString & convertQuotedPrintableString(UnicodeString & stringToConvert);
|
||||
};
|
||||
|
||||
#endif /* __ICALREADER_H_ */
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "jdefines.h"
|
||||
|
||||
#include "icalfrdr.h"
|
||||
|
||||
#include "icalredr.h"
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
ICalFileReader::ICalFileReader() {}
|
||||
|
@ -100,7 +100,8 @@ ICalFileReader::readFullLine(UnicodeString & aLine, ErrorCode & status, t_int32
|
|||
{
|
||||
status = ZERO_ERROR;
|
||||
t_int8 i;
|
||||
|
||||
t_bool qp = FALSE;
|
||||
|
||||
readLine(aLine, status);
|
||||
//if (FALSE) TRACE("rfl(1) %s\r\n", aLine.toCString(""));
|
||||
|
||||
|
@ -108,14 +109,51 @@ ICalFileReader::readFullLine(UnicodeString & aLine, ErrorCode & status, t_int32
|
|||
{
|
||||
return aLine;
|
||||
}
|
||||
|
||||
if (aLine.indexOf("QUOTED-PRINTABLE") >= 0 || aLine.indexOf("quoted-printable") >= 0)
|
||||
qp = TRUE;
|
||||
if (qp)
|
||||
{
|
||||
// convert string after ':'
|
||||
t_int32 i;
|
||||
i = aLine.indexOf(':');
|
||||
if (i >= 0)
|
||||
{
|
||||
UnicodeString u;
|
||||
u = aLine.extractBetween(i + 1, aLine.size(), u);
|
||||
u = ICalReader::convertQuotedPrintableString(u);
|
||||
aLine.replaceBetween(i + 1, aLine.size(), u);
|
||||
}
|
||||
if (aLine[(TextOffset) aLine.size() - 1] == '=')
|
||||
aLine.remove((TextOffset) aLine.size() - 1, 1);
|
||||
else
|
||||
qp = FALSE;
|
||||
}
|
||||
|
||||
UnicodeString aSubLine;
|
||||
while (TRUE)
|
||||
{
|
||||
i = read(status);
|
||||
if (i != -1 && i == ' ')
|
||||
if (i != -1 && i == ' ' || (qp && i != -1))
|
||||
{
|
||||
aLine += readLine(aSubLine, status);
|
||||
//if (FALSE) TRACE("rfl(2) %s\r\n", aLine.toCString(""));
|
||||
if (!qp)
|
||||
{
|
||||
aLine += readLine(aSubLine, status);
|
||||
}
|
||||
else
|
||||
{
|
||||
aLine += i;
|
||||
aSubLine = readLine(aSubLine, status);
|
||||
// convert aSubLine;
|
||||
aSubLine = ICalReader::convertQuotedPrintableString(aSubLine);
|
||||
// remove last '=' if it exists, if it doesn't we're done.
|
||||
if (aSubLine[(TextOffset) aSubLine.size() - 1] == '=')
|
||||
aSubLine.remove((TextOffset) aSubLine.size() - 1, 1);
|
||||
else
|
||||
qp = FALSE;
|
||||
|
||||
aLine += aSubLine;
|
||||
}
|
||||
}
|
||||
else if (i == -1)
|
||||
{
|
||||
|
|
|
@ -69,3 +69,39 @@ t_int8 ICalReader::convertHex(char fToken,
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
UnicodeString &
|
||||
ICalReader::convertQuotedPrintableString(UnicodeString & stringToConvert)
|
||||
{
|
||||
t_int32 iEqual = -1;
|
||||
t_int32 iCurrentPos = 0;
|
||||
t_bool done = FALSE;
|
||||
while (!done)
|
||||
{
|
||||
iEqual = stringToConvert.indexOf('=', iCurrentPos);
|
||||
if (iEqual < 0)
|
||||
done = TRUE;
|
||||
else
|
||||
{
|
||||
if (stringToConvert.size() >= iEqual + 3)
|
||||
{
|
||||
if (ICalReader::isHex((char) stringToConvert[(TextOffset)(iEqual + 1)]) &&
|
||||
ICalReader::isHex((char) stringToConvert[(TextOffset)(iEqual + 2)]))
|
||||
{
|
||||
t_int8 c;
|
||||
c = ICalReader::convertHex((char) stringToConvert[(TextOffset)(iEqual+1)],
|
||||
(char) stringToConvert[(TextOffset)(iEqual+2)]);
|
||||
UnicodeString u;
|
||||
u+=c;
|
||||
stringToConvert.replace(iEqual, 3, u);
|
||||
iCurrentPos = iEqual + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
done = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return stringToConvert;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ all const char * passed in will be us-ascii 8-bit chars
|
|||
#include <string.h>
|
||||
#include "ptypes.h"
|
||||
#include "icalsrdr.h"
|
||||
|
||||
#include "icalredr.h"
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
ICalStringReader::ICalStringReader() {}
|
||||
|
@ -173,6 +173,7 @@ UnicodeString & ICalStringReader::readFullLine(UnicodeString & aLine,
|
|||
{
|
||||
status = ZERO_ERROR;
|
||||
t_int32 i;
|
||||
t_bool qp = FALSE;
|
||||
|
||||
readLine(aLine, status);
|
||||
//if (FALSE) TRACE("rfl(1) %s\r\n", aLine.toCString(""));
|
||||
|
@ -182,17 +183,52 @@ UnicodeString & ICalStringReader::readFullLine(UnicodeString & aLine,
|
|||
//aLine = "";
|
||||
return aLine;
|
||||
}
|
||||
|
||||
UnicodeString aSubLine;
|
||||
|
||||
if (aLine.indexOf("QUOTED-PRINTABLE") >= 0 || aLine.indexOf("quoted-printable") >=0 )
|
||||
qp = TRUE;
|
||||
if (qp)
|
||||
{
|
||||
// convert string after ':'
|
||||
t_int32 i;
|
||||
i = aLine.indexOf(':');
|
||||
if (i >= 0)
|
||||
{
|
||||
UnicodeString u;
|
||||
u = aLine.extractBetween(i + 1, aLine.size(), u);
|
||||
u = ICalReader::convertQuotedPrintableString(u);
|
||||
aLine.replaceBetween(i + 1, aLine.size(), u);
|
||||
}
|
||||
if (aLine[(TextOffset) aLine.size() - 1] == '=')
|
||||
aLine.remove((TextOffset) aLine.size() - 1, 1);
|
||||
else
|
||||
qp = FALSE;
|
||||
}
|
||||
|
||||
UnicodeString aSubLine;
|
||||
while (TRUE)
|
||||
{
|
||||
mark();
|
||||
i = read(status);
|
||||
if (i == ' ')
|
||||
if (i == ' ' || (qp && i != -1))
|
||||
{
|
||||
aLine += readLine(aSubLine, status);
|
||||
//if (FALSE) TRACE("rfl(2) %s\r\n", aLine.toCString(""));
|
||||
if (!qp)
|
||||
{
|
||||
aLine += readLine(aSubLine, status);
|
||||
}
|
||||
else
|
||||
{
|
||||
aLine += i;
|
||||
aSubLine = readLine(aSubLine, status);
|
||||
// convert aSubLine;
|
||||
aSubLine = ICalReader::convertQuotedPrintableString(aSubLine);
|
||||
// remove last '=' if it exists, if it doesn't we're done.
|
||||
if (aSubLine[(TextOffset) aSubLine.size() - 1] == '=')
|
||||
aSubLine.remove((TextOffset) aSubLine.size() - 1, 1);
|
||||
else
|
||||
qp = FALSE;
|
||||
|
||||
aLine += aSubLine;
|
||||
}
|
||||
}
|
||||
else if (FAILURE(status))
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче