unfold all headers per RFC 822: bug 23635 r=ducarroz sr=bienvenu

This commit is contained in:
jgmyers%netscape.com 2001-01-26 23:41:08 +00:00
Родитель aca723ed2d
Коммит 7b76729eb8
2 изменённых файлов: 22 добавлений и 28 удалений

Просмотреть файл

@ -1477,23 +1477,26 @@ extern "C" char *MIME_DecodeMimePartIIStr(const char *header, char *charset,
// If no MIME encoded then do nothing otherwise decode the input.
if (*header != '\0' && intlmime_is_mime_part2_header(header)) {
result = intl_decode_mime_part2_str(header, charset);
if (eatContinuations)
result = MIME_StripContinuations(result);
}
else if (*charset == '\0') {
// no charset name is specified then assume it's us-ascii (or ISO-8859-1 if 8bit)
// and dup the input (later change the caller to avoid the duplication)
unsigned char *cp = (unsigned char *) header;
PL_strcpy(charset, "us-ascii");
while (*cp) {
if (*cp > 127) {
PL_strcpy(charset, "ISO-8859-1");
break;
else
{
if (*charset == '\0') {
// no charset name is specified then assume it's us-ascii (or ISO-8859-1 if 8bit)
// and dup the input (later change the caller to avoid the duplication)
unsigned char *cp = (unsigned char *) header;
PL_strcpy(charset, "us-ascii");
while (*cp) {
if (*cp > 127) {
PL_strcpy(charset, "ISO-8859-1");
break;
}
cp++;
}
cp++;
}
return nsCRT::strdup(header);
result = nsCRT::strdup(header);
}
if (eatContinuations)
result = MIME_StripContinuations(result);
return result;
}

Просмотреть файл

@ -850,7 +850,7 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
HG99401
#endif /* MOZ_SECURITY */
/* Strip CR+LF+<whitespace> runs within (original).
/* Strip CR+LF runs within (original).
Since the string at (original) can only shrink,
this conversion is done in place. (original)
is returned. */
@ -867,22 +867,13 @@ MIME_StripContinuations(char *original)
while(*p2)
{
/* p2 runs ahead at (CR and/or LF) + <space> */
/* p2 runs ahead at (CR and/or LF) */
if ((p2[0] == CR) || (p2[0] == LF))
{
/* move past (CR and/or LF) + whitespace following */
do
{
p2++;
}
while((*p2 == CR) || (*p2 == LF) || nsCRT::IsAsciiSpace(*p2));
if (*p2 == '\0') continue; /* drop out of loop at end of string*/
}
/* Copy the next non-linebreaking char */
*p1 = *p2;
p1++; p2++;
p2++;
} else {
*p1++ = *p2++;
}
}
*p1 = '\0';