lineResult2 += NS_LITERAL_STRING("<br>");
lineResult2.AppendLiteral("<br>");
MimeInlineTextPlainFlowed_parse_line (char *line, PRInt32 length, MimeObject *obj){  int status;  PRBool quoting = ( obj->options    && ( obj->options->format_out == nsMimeOutput::nsMimeMessageQuoting ||         obj->options->format_out == nsMimeOutput::nsMimeMessageBodyQuoting       )           );  // see above  PRBool plainHTML = quoting || (obj->options &&       obj->options->format_out == nsMimeOutput::nsMimeMessageSaveAs);       // see above  struct MimeInlineTextPlainFlowedExData *exdata;  exdata = MimeInlineTextPlainFlowedExDataList;  while(exdata && (exdata->ownerobj != obj)) {    exdata = exdata->next;  }  NS_ASSERTION(exdata, "The extra data has disappeared!");  NS_ASSERTION(length > 0, "zero length");  if (length <= 0) return 0;  uint32 linequotelevel = 0;  char *linep = line;  // Space stuffed?  if(' ' == *linep) {    linep++;  } else {    // count '>':s before the first non-'>'    while('>' == *linep) {      linep++;      linequotelevel++;    }    // Space stuffed?    if(' ' == *linep) {      linep++;    }  }  // Look if the last character (after stripping ending end  // of lines and quoting stuff) is a SPACE. If it is, we are looking at a  // flowed line. Normally we assume that the last two chars  // are CR and LF as said in RFC822, but that doesn't seem to  // be the case always.  PRBool flowed = PR_FALSE;  PRInt32 index = length-1;  while(index >= 0 && ('\r' == line[index] || '\n' == line[index])) {    index--;  }  if (index > linep - line && ' ' == line[index])       /* Ignore space stuffing, i.e. lines with just          (quote marks and) a space count as empty */    flowed = PR_TRUE;  mozITXTToHTMLConv *conv = GetTextConverter(obj->options);  PRBool skipConversion = !conv ||                          (obj->options && obj->options->force_user_charset);  nsAutoString lineSource;  nsXPIDLString lineResult;      char *mailCharset = NULL;  nsresult rv;  if (!skipConversion)  {    // Convert only if the source string is not empty    if (length - (linep - line) > 0)    {      PRBool whattodo = obj->options->whattodo;      if (plainHTML)      {        if (quoting)          whattodo = 0;        else          whattodo = whattodo & ~mozITXTToHTMLConv::kGlyphSubstitution;                    /* Do recognition for the case, the result is viewed in                        Mozilla, but not GlyphSubstitution, because other UAs                        might not be able to display the glyphs. */      }      nsDependentCString inputStr(linep, length - (linep - line));      // For 'SaveAs', |line| is in |mailCharset|.      // convert |line| to UTF-16 before 'html'izing (calling ScanTXT())      if (obj->options->format_out == nsMimeOutput::nsMimeMessageSaveAs)      {        // Get the mail charset of this message.        MimeInlineText  *inlinetext = (MimeInlineText *) obj;        if (!inlinetext->initializeCharset)          ((MimeInlineTextClass*)&mimeInlineTextClass)->initialize_charset(obj);        mailCharset = inlinetext->charset;        if (mailCharset && *mailCharset) {          rv = nsMsgI18NConvertToUnicode(mailCharset, inputStr, lineSource);          NS_ENSURE_SUCCESS(rv, -1);        }        else // this probably never happens...          CopyUTF8toUTF16(inputStr, lineSource);      }      else   // line is in UTF-8        CopyUTF8toUTF16(inputStr, lineSource);      // This is the main TXT to HTML conversion:      // escaping (very important), eventually recognizing etc.      rv = conv->ScanTXT(lineSource.get(), whattodo, getter_Copies(lineResult));      NS_ENSURE_SUCCESS(rv, -1);    }  }  else  {    CopyUTF8toUTF16(nsDependentCString(line, length), lineResult);    status = NS_OK;  }  nsCAutoString preface;  /* Correct number of blockquotes */  int32 quoteleveldiff=linequotelevel - exdata->quotelevel;  if((quoteleveldiff != 0) && flowed && exdata->inflow) {    // From RFC 2646 4.5    // The receiver SHOULD handle this error by using the 'quote-depth-wins' rule,    // which is to ignore the flowed indicator and treat the line as fixed.  That    // is, the change in quote depth ends the paragraph.    // We get that behaviour by just going on.  }  while(quoteleveldiff>0) {    quoteleveldiff--;    preface += "<blockquote type=cite";    // This is to have us observe the user pref settings for citations    MimeInlineTextPlainFlowed *tObj = (MimeInlineTextPlainFlowed *) obj;    nsCAutoString style;    MimeTextBuildPrefixCSS(tObj->mQuotedSizeSetting, tObj->mQuotedStyleSetting,                           tObj->mCitationColor, style);    if (!plainHTML && !style.IsEmpty())    {      preface += " style=\"";      preface += style;      preface += '"';    }    preface += '>';  }  while(quoteleveldiff<0) {    quoteleveldiff++;    preface += "</blockquote>";  }  exdata->quotelevel = linequotelevel;  nsAutoString lineResult2;  if(flowed) {    // Check RFC 2646 "4.3. Usenet Signature Convention": "-- "+CRLF is    // not a flowed line    if      (  // is "-- "LINEBREAK        lineSource.Length() >= 4        && lineSource[0] == '-'        &&        (          Substring(lineSource, 0, 4).EqualsLiteral("-- \r") ||          Substring(lineSource, 0, 4).EqualsLiteral("-- \n")        )      )    {      if (linequotelevel > 0 || exdata->isSig)      {        preface += "--&nbsp;<br>";      } else {        exdata->isSig = PR_TRUE;        preface += "<div class=\"moz-txt-sig\"><span class=\"moz-txt-tag\">"                   "--&nbsp;<br></span>";      }    } else {      Line_convert_whitespace(lineResult, PR_FALSE /* Allow wraps */,                              lineResult2);    }    exdata->inflow=PR_TRUE;  } else {    // Fixed paragraph.    Line_convert_whitespace(lineResult,                            !plainHTML && !obj->options->wrap_long_lines_p                              /* If wrap, convert all spaces but the last in                                 a row into nbsp, otherwise all. */,                            lineResult2);    lineResult2 += NS_LITERAL_STRING("<br>");    exdata->inflow = PR_FALSE;  } // End Fixed line  if (!(exdata->isSig && quoting))  {    status = MimeObject_write(obj, preface.get(), preface.Length(), PR_TRUE);    if (status < 0) return status;    nsCAutoString outString;    if (obj->options->format_out != nsMimeOutput::nsMimeMessageSaveAs ||        !mailCharset || !*mailCharset)      CopyUTF16toUTF8(lineResult2, outString);    else    { // convert back to mailCharset before writing.             rv = nsMsgI18NConvertFromUnicode(mailCharset, lineResult2, outString);      NS_ENSURE_SUCCESS(rv, -1);    }    status = MimeObject_write(obj, outString.get(), outString.Length(), PR_TRUE);    return status;  }  else    return NS_OK;}