From 8d98c524887e34d1c8c651f086040995cad3a547 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Fri, 4 Nov 2011 17:44:13 +0900 Subject: [PATCH] Bug 254298 - nsPlainTextSerializer.cpp should not use AssignWithConversion. r=smaug --- content/base/src/nsPlainTextSerializer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/content/base/src/nsPlainTextSerializer.cpp b/content/base/src/nsPlainTextSerializer.cpp index 65a91f42ed9..dfdf4b5270c 100644 --- a/content/base/src/nsPlainTextSerializer.cpp +++ b/content/base/src/nsPlainTextSerializer.cpp @@ -307,8 +307,6 @@ nsPlainTextSerializer::AppendText(nsIContent* aText, NS_ENSURE_ARG(aText); nsresult rv = NS_OK; - PRInt32 length = 0; - nsAutoString textstr; nsIContent* content = aText; const nsTextFragment* frag; @@ -319,16 +317,19 @@ nsPlainTextSerializer::AppendText(nsIContent* aText, PRInt32 endoffset = (aEndOffset == -1) ? frag->GetLength() : aEndOffset; NS_ASSERTION(aStartOffset <= endoffset, "A start offset is beyond the end of the text fragment!"); - length = endoffset - aStartOffset; + PRInt32 length = endoffset - aStartOffset; if (length <= 0) { return NS_OK; } + nsAutoString textstr; if (frag->Is2b()) { textstr.Assign(frag->Get2b() + aStartOffset, length); } else { - textstr.AssignWithConversion(frag->Get1b()+aStartOffset, length); + // AssignASCII is for 7-bit character only, so don't use it + const char *data = frag->Get1b(); + CopyASCIItoUTF16(Substring(data + aStartOffset, data + endoffset), textstr); } mOutputString = &aStr;