From 2942a58e82764db90b84dafba49129f002cd541a Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Tue, 19 Oct 1999 08:52:30 +0000 Subject: [PATCH] fixed bug 16584; CRCRLF not handled correctly. r=syd --- htmlparser/src/nsHTMLTokens.cpp | 46 +++++++++++++++++--------- parser/htmlparser/src/nsHTMLTokens.cpp | 46 +++++++++++++++++--------- 2 files changed, 60 insertions(+), 32 deletions(-) diff --git a/htmlparser/src/nsHTMLTokens.cpp b/htmlparser/src/nsHTMLTokens.cpp index 541611626e7c..2289809b7cad 100644 --- a/htmlparser/src/nsHTMLTokens.cpp +++ b/htmlparser/src/nsHTMLTokens.cpp @@ -443,24 +443,38 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) result=aScanner.ReadUntil(mTextValue,theTerminals,PR_TRUE,PR_FALSE); if(NS_OK==result) { result=aScanner.Peek(aChar); + if(((kCR==aChar) || (kNewLine==aChar)) && (NS_OK==result)) { - result=aScanner.GetChar(aChar); //strip off the \r - result=aScanner.Peek(aChar); //then see what's next. - if(NS_OK==result) { - switch(aChar) { - case kCR: - result=aScanner.GetChar(aChar); //strip off the \r - mTextValue.Append("\n\n"); - break; - case kNewLine: - //which means we saw \r\n, which becomes \n - result=aScanner.GetChar(aChar); //strip off the \n - //now fall through on purpose... - default: + result=aScanner.GetChar(aChar); //strip off the char + PRUnichar theNextChar; + result=aScanner.Peek(theNextChar); //then see what's next. + switch(aChar) { + case kCR: + // result=aScanner.GetChar(aChar); + if(kLF==theNextChar) { + result=aScanner.GetChar(theNextChar); + } + else if(kCR==theNextChar) { + result=aScanner.GetChar(theNextChar); + result=aScanner.Peek(theNextChar); //then see what's next. + if(kLF==theNextChar) { + result=aScanner.GetChar(theNextChar); + } mTextValue.Append("\n"); - break; - }//switch - }//if + } + mTextValue.Append("\n"); + break; + case kLF: + if((kLF==theNextChar) || (kCR==theNextChar)) { + result=aScanner.GetChar(theNextChar); + mTextValue.Append("\n"); + } + mTextValue.Append("\n"); + break; + default: + mTextValue.Append("\n"); + break; + } //switch } else done=PR_TRUE; } diff --git a/parser/htmlparser/src/nsHTMLTokens.cpp b/parser/htmlparser/src/nsHTMLTokens.cpp index 541611626e7c..2289809b7cad 100644 --- a/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/parser/htmlparser/src/nsHTMLTokens.cpp @@ -443,24 +443,38 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) result=aScanner.ReadUntil(mTextValue,theTerminals,PR_TRUE,PR_FALSE); if(NS_OK==result) { result=aScanner.Peek(aChar); + if(((kCR==aChar) || (kNewLine==aChar)) && (NS_OK==result)) { - result=aScanner.GetChar(aChar); //strip off the \r - result=aScanner.Peek(aChar); //then see what's next. - if(NS_OK==result) { - switch(aChar) { - case kCR: - result=aScanner.GetChar(aChar); //strip off the \r - mTextValue.Append("\n\n"); - break; - case kNewLine: - //which means we saw \r\n, which becomes \n - result=aScanner.GetChar(aChar); //strip off the \n - //now fall through on purpose... - default: + result=aScanner.GetChar(aChar); //strip off the char + PRUnichar theNextChar; + result=aScanner.Peek(theNextChar); //then see what's next. + switch(aChar) { + case kCR: + // result=aScanner.GetChar(aChar); + if(kLF==theNextChar) { + result=aScanner.GetChar(theNextChar); + } + else if(kCR==theNextChar) { + result=aScanner.GetChar(theNextChar); + result=aScanner.Peek(theNextChar); //then see what's next. + if(kLF==theNextChar) { + result=aScanner.GetChar(theNextChar); + } mTextValue.Append("\n"); - break; - }//switch - }//if + } + mTextValue.Append("\n"); + break; + case kLF: + if((kLF==theNextChar) || (kCR==theNextChar)) { + result=aScanner.GetChar(theNextChar); + mTextValue.Append("\n"); + } + mTextValue.Append("\n"); + break; + default: + mTextValue.Append("\n"); + break; + } //switch } else done=PR_TRUE; }