View | Details | Raw Unified | Return to bug 14378
Collapse All | Expand All

(-)mozilla/mailnews/base/util/nsMsgDBFolder.cpp.orig (-1 / +8 lines)
Lines 5232-5247 NS_IMETHODIMP nsMsgDBFolder::GetMsgTextF Link Here
5232
5232
5233
  nsCString msgText;
5233
  nsCString msgText;
5234
  nsCAutoString encoding;
5234
  nsCAutoString encoding;
5235
  nsCAutoString boundary;
5235
  nsCAutoString boundary;
5236
  nsCAutoString curLine;
5236
  nsCAutoString curLine;
5237
  
5237
  
5238
  // might want to use a state var instead of bools.
5238
  // might want to use a state var instead of bools.
5239
  PRBool inMsgBody = PR_FALSE, msgBodyIsHtml = PR_FALSE, lookingForBoundary = PR_FALSE;
5239
  PRBool inMsgBody = PR_FALSE, msgBodyIsHtml = PR_FALSE, lookingForBoundary = PR_FALSE;
5240
  PRBool lookingForCharset = PR_FALSE;
5240
  PRBool haveBoundary = PR_FALSE;
5241
  PRBool haveBoundary = PR_FALSE;
5241
  PRBool isBase64 = PR_FALSE;
5242
  PRBool isBase64 = PR_FALSE;
5242
  PRBool reachedEndBody = bytesToRead >= len;
5243
  PRBool reachedEndBody = bytesToRead >= len;
5243
  PRBool more = PR_TRUE;
5244
  PRBool more = PR_TRUE;
5244
  while (len > 0 && more)
5245
  while (len > 0 && more)
5245
  {
5246
  {
5246
    // might be on same line as content-type, so look before
5247
    // might be on same line as content-type, so look before
5247
    // we read the next line.
5248
    // we read the next line.
Lines 5296-5317 NS_IMETHODIMP nsMsgDBFolder::GetMsgTextF Link Here
5296
        continue;
5297
        continue;
5297
      }
5298
      }
5298
      if (curLine.IsEmpty())
5299
      if (curLine.IsEmpty())
5299
      {
5300
      {
5300
        inMsgBody = PR_TRUE;
5301
        inMsgBody = PR_TRUE;
5301
        continue;
5302
        continue;
5302
      }
5303
      }
5303
      if (StringBeginsWith(curLine, NS_LITERAL_CSTRING("Content-Type:"),
5304
      if (StringBeginsWith(curLine, NS_LITERAL_CSTRING("Content-Type:"),
5304
                           nsCaseInsensitiveCStringComparator()))
5305
                           nsCaseInsensitiveCStringComparator()) ||
5306
                           lookingForCharset)
5305
      {
5307
      {
5306
        // look for a charset in the Content-Type header line, we'll take the first one we find.
5308
        // look for a charset in the Content-Type header line, we'll take the first one we find.
5307
        nsCOMPtr<nsIMIMEHeaderParam> mimehdrpar = do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv);
5309
        nsCOMPtr<nsIMIMEHeaderParam> mimehdrpar = do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv);
5308
        if (NS_SUCCEEDED(rv) && charset.IsEmpty())
5310
        if (NS_SUCCEEDED(rv) && charset.IsEmpty())
5309
          mimehdrpar->GetParameter(curLine, "charset", EmptyCString(), false, nsnull, charset);
5311
          mimehdrpar->GetParameter(curLine, "charset", EmptyCString(), false, nsnull, charset);
5312
        // if the Content-Type header is multiline, look for a charset in other lines
5313
        if (charset.IsEmpty())
5314
          lookingForCharset = PR_TRUE;
5315
        else if (lookingForCharset || (curLine[0] != ' ' && curLine[0] != '\t'))
5316
          lookingForCharset = PR_FALSE;
5310
        if (FindInReadable(NS_LITERAL_CSTRING("text/html"), curLine,
5317
        if (FindInReadable(NS_LITERAL_CSTRING("text/html"), curLine,
5311
                           nsCaseInsensitiveCStringComparator()))
5318
                           nsCaseInsensitiveCStringComparator()))
5312
          msgBodyIsHtml = PR_TRUE;
5319
          msgBodyIsHtml = PR_TRUE;
5313
        else if (FindInReadable(NS_LITERAL_CSTRING("multipart/"), curLine,
5320
        else if (FindInReadable(NS_LITERAL_CSTRING("multipart/"), curLine,
5314
                                nsCaseInsensitiveCStringComparator()))
5321
                                nsCaseInsensitiveCStringComparator()))
5315
          lookingForBoundary = PR_TRUE;
5322
          lookingForBoundary = PR_TRUE;
5316
      }
5323
      }
5317
      else if (StringBeginsWith(curLine, NS_LITERAL_CSTRING("Content-Transfer-Encoding:"),
5324
      else if (StringBeginsWith(curLine, NS_LITERAL_CSTRING("Content-Transfer-Encoding:"),
(-)mozilla/mailnews/db/msgdb/src/nsMsgDatabase.cpp.orig (-7 / +27 lines)
Lines 3180-3201 nsresult nsMsgDatabase::RowCellColumnToM Link Here
3180
  const char *nakedString = nsnull;
3180
  const char *nakedString = nsnull;
3181
  err = RowCellColumnToConstCharPtr(row, columnToken, &nakedString);
3181
  err = RowCellColumnToConstCharPtr(row, columnToken, &nakedString);
3182
  if (NS_SUCCEEDED(err) && nakedString && strlen(nakedString))
3182
  if (NS_SUCCEEDED(err) && nakedString && strlen(nakedString))
3183
  {
3183
  {
3184
    GetMimeConverter();
3184
    GetMimeConverter();
3185
    if (m_mimeConverter) 
3185
    if (m_mimeConverter) 
3186
    {
3186
    {
3187
      nsAutoString decodedStr;
3187
      nsAutoString decodedStr;
3188
      const char *charSet;
3188
      char *charSet;
3189
      PRBool characterSetOverride;
3189
      PRBool characterSetOverride;
3190
      m_dbFolderInfo->GetConstCharPtrCharacterSet(&charSet);
3191
      m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
3190
      m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
3192
      
3191
      err = RowCellColumnToCharPtr(row, m_messageCharSetColumnToken, &charSet);
3192
      if (NS_FAILED(err) || !*charSet || !PL_strcasecmp(charSet, "us-ascii") ||
3193
          characterSetOverride)
3194
      {
3195
        PR_Free(charSet);
3196
        m_dbFolderInfo->GetCharPtrCharacterSet(&charSet);
3197
      }
3198
3193
      err = m_mimeConverter->DecodeMimeHeader(nakedString, resultStr, charSet, characterSetOverride);
3199
      err = m_mimeConverter->DecodeMimeHeader(nakedString, resultStr, charSet, characterSetOverride);
3200
      PR_Free(charSet);
3194
    }
3201
    }
3195
  }
3202
  }
3196
  return err;
3203
  return err;
3197
}
3204
}
3198
3205
3199
nsresult nsMsgDatabase::RowCellColumnToAddressCollationKey(nsIMdbRow *row, mdb_token colToken, PRUint8 **result, PRUint32 *len)
3206
nsresult nsMsgDatabase::RowCellColumnToAddressCollationKey(nsIMdbRow *row, mdb_token colToken, PRUint8 **result, PRUint32 *len)
3200
{
3207
{
3201
  const char *cSender;
3208
  const char *cSender;
Lines 3210-3228 nsresult nsMsgDatabase::RowCellColumnToA Link Here
3210
      // apply mime decode
3217
      // apply mime decode
3211
      nsIMimeConverter *converter = GetMimeConverter();
3218
      nsIMimeConverter *converter = GetMimeConverter();
3212
      
3219
      
3213
      if (NS_SUCCEEDED(ret) && nsnull != converter) 
3220
      if (NS_SUCCEEDED(ret) && nsnull != converter) 
3214
      {
3221
      {
3215
        char *resultStr = nsnull;
3222
        char *resultStr = nsnull;
3216
        char *charset;
3223
        char *charset;
3217
        PRBool characterSetOverride;
3224
        PRBool characterSetOverride;
3218
        m_dbFolderInfo->GetCharPtrCharacterSet(&charset);
3219
        m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
3225
        m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
3220
        
3226
        ret = RowCellColumnToCharPtr(row, m_messageCharSetColumnToken, &charset);
3227
        if (NS_FAILED(ret) || !*charset || !PL_strcasecmp(charset, "us-ascii") ||
3228
            characterSetOverride)
3229
        {
3230
          PR_Free(charset);
3231
          m_dbFolderInfo->GetCharPtrCharacterSet(&charset);
3232
        }
3233
3221
        ret = converter->DecodeMimeHeader(cSender, &resultStr,
3234
        ret = converter->DecodeMimeHeader(cSender, &resultStr,
3222
          charset, characterSetOverride);
3235
          charset, characterSetOverride);
3223
        if (NS_SUCCEEDED(ret) && resultStr)
3236
        if (NS_SUCCEEDED(ret) && resultStr)
3224
        {
3237
        {
3225
          ret = headerParser->ExtractHeaderAddressName ("UTF-8", resultStr, getter_Copies(name));
3238
          ret = headerParser->ExtractHeaderAddressName ("UTF-8", resultStr, getter_Copies(name));
3226
        }
3239
        }
3227
        else {
3240
        else {
3228
          ret = headerParser->ExtractHeaderAddressName ("UTF-8", cSender, getter_Copies(name));
3241
          ret = headerParser->ExtractHeaderAddressName ("UTF-8", cSender, getter_Copies(name));
Lines 3280-3303 nsresult nsMsgDatabase::RowCellColumnToC Link Here
3280
  
3293
  
3281
  err = RowCellColumnToConstCharPtr(row, columnToken, &nakedString);
3294
  err = RowCellColumnToConstCharPtr(row, columnToken, &nakedString);
3282
  if (NS_SUCCEEDED(err))
3295
  if (NS_SUCCEEDED(err))
3283
  {
3296
  {
3284
    GetMimeConverter();
3297
    GetMimeConverter();
3285
    if (m_mimeConverter) 
3298
    if (m_mimeConverter) 
3286
    {
3299
    {
3287
      nsXPIDLCString decodedStr;
3300
      nsXPIDLCString decodedStr;
3288
      const char *charSet;
3301
      char *charSet;
3289
      PRBool characterSetOverride;
3302
      PRBool characterSetOverride;
3290
      m_dbFolderInfo->GetConstCharPtrCharacterSet(&charSet);
3291
      m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
3303
      m_dbFolderInfo->GetCharacterSetOverride(&characterSetOverride);
3304
      err = RowCellColumnToCharPtr(row, m_messageCharSetColumnToken, &charSet);
3305
      if (NS_FAILED(err) || !*charSet || !PL_strcasecmp(charSet, "us-ascii") ||
3306
          characterSetOverride)
3307
      {
3308
        PR_Free(charSet);
3309
        m_dbFolderInfo->GetCharPtrCharacterSet(&charSet);
3310
      }
3292
      
3311
      
3293
      err = m_mimeConverter->DecodeMimeHeader(nakedString, getter_Copies(decodedStr), charSet, characterSetOverride);
3312
      err = m_mimeConverter->DecodeMimeHeader(nakedString, getter_Copies(decodedStr), charSet, characterSetOverride);
3294
      if (NS_SUCCEEDED(err))
3313
      if (NS_SUCCEEDED(err))
3295
        err = CreateCollationKey(NS_ConvertUTF8toUCS2(decodedStr), result, len);
3314
        err = CreateCollationKey(NS_ConvertUTF8toUCS2(decodedStr), result, len);
3315
      PR_Free(charSet);
3296
    }
3316
    }
3297
  }
3317
  }
3298
  return err;
3318
  return err;
3299
}
3319
}
3300
3320
3301
NS_IMETHODIMP 
3321
NS_IMETHODIMP 
3302
nsMsgDatabase::CompareCollationKeys(PRUint8 *key1, PRUint32 len1, PRUint8 *key2, PRUint32 len2, PRInt32 *result)
3322
nsMsgDatabase::CompareCollationKeys(PRUint8 *key1, PRUint32 len1, PRUint8 *key2, PRUint32 len2, PRInt32 *result)
3303
{
3323
{
(-)mozilla/mailnews/mime/src/mimemsg.cpp.orig (+13 lines)
Lines 744-759 MimeMessage_write_headers_html (MimeObje Link Here
744
  // reply and forward operations.
744
  // reply and forward operations.
745
  //
745
  //
746
  char    *mailCharset = DetermineMailCharset(msg);
746
  char    *mailCharset = DetermineMailCharset(msg);
747
  mimeEmitterStartHeader(obj->options, 
747
  mimeEmitterStartHeader(obj->options, 
748
                            outer_p, 
748
                            outer_p, 
749
                            (obj->options->headers == MimeHeadersOnly),
749
                            (obj->options->headers == MimeHeadersOnly),
750
                            msgID,
750
                            msgID,
751
                            mailCharset);
751
                            mailCharset);
752
753
  // Change the default_charset by the charset of the original message
754
  // ONLY WHEN THE CHARSET OF THE ORIGINAL MESSAGE IS NOT US-ASCII
755
  // ("ISO-8859-1") and defailt_charset and mailCharset are different.
756
  if ( (mailCharset) && (PL_strcasecmp(mailCharset, "US-ASCII")) &&
757
       (PL_strcasecmp(mailCharset, "ISO-8859-1")) &&
758
       (PL_strcasecmp(obj->options->default_charset, mailCharset)) &&
759
       !obj->options->override_charset )
760
  {
761
    PR_Free(obj->options->default_charset);
762
    obj->options->default_charset = strdup(mailCharset);
763
  }
764
752
  PR_FREEIF(msgID);
765
  PR_FREEIF(msgID);
753
  PR_FREEIF(mailCharset);
766
  PR_FREEIF(mailCharset);
754
767
755
#ifdef MOZ_SECURITY
768
#ifdef MOZ_SECURITY
756
    HG00919 
769
    HG00919 
757
#endif /* MOZ_SECURITY */
770
#endif /* MOZ_SECURITY */
758
771
759
  status = MimeHeaders_write_all_headers (msg->hdrs, obj->options, PR_FALSE);
772
  status = MimeHeaders_write_all_headers (msg->hdrs, obj->options, PR_FALSE);

Return to bug 14378