diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp
index ef935e3ad6f..7003d5dfae8 100644
--- a/mozilla/htmlparser/src/nsParser.cpp
+++ b/mozilla/htmlparser/src/nsParser.cpp
@@ -24,6 +24,8 @@
#define DEBUG_XMLENCODING
#define XMLENCODING_PEEKBYTES 64
//#define TEST_DOCTYPES
+//#define DISABLE_TRANSITIONAL_MODE
+
#include "nsParser.h"
#include "nsIContentSink.h"
@@ -466,6 +468,108 @@ nsDTDMode nsParser::GetParseMode(void){
}
+
+class CWordTokenizer {
+public:
+ CWordTokenizer(nsString& aString,PRInt32 aStartOffset,PRInt32 aMaxOffset) {
+ mLength=0;
+ mOffset=aStartOffset;
+ mMaxOffset=aMaxOffset;
+ mBuffer=aString.GetUnicode();
+ mEndBuffer=mBuffer+mMaxOffset;
+ }
+
+ //********************************************************************************
+ // Get offset of nth word in string.
+ // We define words as:
+ // 1) sequence of alphanum;
+ // 2) quoted substring
+ // 3) SGML comment -- ... --
+ // Returns offset of nth word, or -1 (if out of words).
+ //********************************************************************************
+
+ PRInt32 GetNextWord() {
+
+ const PRUnichar *cp=mBuffer+mOffset+mLength; //skip last word
+
+ mLength=0; //reset this
+ mOffset=-1; //reset this
+
+ //now skip whitespace...
+
+ PRUnichar target=0;
+ PRBool done=PR_FALSE;
+
+ while((!done) && (cp++
- [HTML] [PUBLIC|...] [+|-] [W3C|IETF|...] [DTD] "..." [EN]|...] "..."
+ [HTML] [PUBLIC|SYTEM] [+|-] [W3C|IETF|...] [DTD] "..." [EN]|...] "..."
Here are the new rules for DTD handling; comments welcome:
@@ -502,7 +606,241 @@ nsDTDMode nsParser::GetParseMode(void){
All other doctypes (<4.0), and documents without a doctype are handled in compatibility-mode.
*****************************************************************************************************/
-
+
+static
+PRBool IsLoosePI(nsString& aBuffer,PRInt32 anOffset,PRInt32 aCount) {
+ PRBool result=PR_FALSE;
+
+ if((aBuffer.Find("TRANSITIONAL",PR_TRUE,anOffset,aCount)>kNotFound)||
+ (aBuffer.Find("LOOSE",PR_TRUE,anOffset,aCount)>kNotFound) ||
+ (aBuffer.Find("FRAMESET",PR_TRUE,anOffset,aCount)>kNotFound) ||
+ (aBuffer.Find("LATIN1", PR_TRUE,anOffset,aCount) >kNotFound) ||
+ (aBuffer.Find("SYMBOLS",PR_TRUE,anOffset,aCount) >kNotFound) ||
+ (aBuffer.Find("SPECIAL",PR_TRUE,anOffset,aCount) >kNotFound)) {
+
+ result=PR_TRUE;
+
+ }
+ return result;
+}
+
+/**
+ * This is called when it's time to find out
+ * what mode the parser/DTD should run for this document.
+ * (Each parsercontext can have it's own mode).
+ *
+ * @update gess 06/24/00
+ * @return parsermode (define in nsIParser.h)
+ */
+static
+void DetermineParseMode(nsString& aBuffer,nsDTDMode& aParseMode,eParserDocType& aDocType,const nsString& aMimeType) {
+ const char* theModeStr= PR_GetEnv("PARSE_MODE");
+
+ aParseMode=eDTDMode_quirks;
+ aDocType=eHTML3Text;
+
+
+ //let's eliminate non-HTML as quickly as possible...
+
+ PRInt32 theIndex=aBuffer.Find("?XML",PR_TRUE,0,128);
+ if(kNotFound!=theIndex) {
+ aParseMode=eDTDMode_strict;
+ if(aMimeType.EqualsWithConversion(kHTMLTextContentType)) {
+ //this is here to prevent a crash if someone gives us an XML document,
+ //but necko tells us it's a text/html mimetype.
+ aDocType=eHTML4Text;
+ aParseMode=eDTDMode_strict;
+ }
+ else aDocType=eXMLText;
+ return;
+
+ }
+ else if(aMimeType.EqualsWithConversion(kPlainTextContentType)) {
+ aDocType=ePlainText;
+ aParseMode=eDTDMode_quirks;
+ return;
+ }
+ else if(aMimeType.EqualsWithConversion(kRTFTextContentType)) {
+ aDocType=ePlainText;
+ aParseMode=eDTDMode_quirks;
+ return;
+ }
+
+
+ //now let's see if we have HTML or XHTML...
+
+ PRInt32 theGTPos=aBuffer.FindChar(kGreaterThan);
+
+ if(kNotFound!=theGTPos) {
+
+ const PRUnichar* theBuffer=aBuffer.GetUnicode();
+ CWordTokenizer theTokenizer(aBuffer,1,theGTPos);
+ PRInt32 theOffset=theTokenizer.GetNextWord(); //try to find ?xml, !doctype, etc...
+
+ if((kNotFound!=theOffset) &&
+ (0==nsCRT::strncasecmp(theBuffer+theOffset,"DOCTYPE",theTokenizer.mLength))) {
+
+ //Ok -- so assume it's (X)HTML; now figure out the flavor...
+
+ PRInt32 theIter=0; //prevent infinite loops...
+ PRBool done=PR_FALSE; //use this to quit if we find garbage...
+ PRBool readSystemID=PR_FALSE;
+ nsDTDMode thePublicID=eDTDMode_quirks;
+ nsDTDMode theSystemID=eDTDMode_unknown;
+
+ theOffset=theTokenizer.GetNextWord();
+
+ while((kNotFound!=theOffset) && (!done)) {
+
+ PRUnichar theChar=*(theBuffer+theTokenizer.mOffset);
+ if(kQuote==theChar) {
+
+ if(readSystemID) {
+
+ PRInt32 thePrefix=aBuffer.Find("http://www.w3.org/tr/",PR_TRUE,theOffset,5); //find the prefix
+
+ if(kNotFound!=thePrefix) {
+ thePrefix+=20;
+ if(IsLoosePI(aBuffer,thePrefix,25)) { //find loose.dtd
+ theSystemID=eDTDMode_transitional;
+ }
+ else if(kNotFound!=aBuffer.Find("strict.dtd",PR_TRUE,thePrefix,25)) { //find strict.dtd
+ theSystemID=eDTDMode_strict;
+ }
+ }
+
+ }
+
+ else { //the public ID...
+
+ readSystemID=PR_TRUE;
+
+ PRInt32 theDTDPos=aBuffer.Find("//DTD",PR_TRUE,theOffset,theTokenizer.mLength);
+ if(theDTDPos) {
+
+ //first, let's see if it's XHML...
+ PRInt32 theMLTagPos=aBuffer.Find("XHTML",PR_TRUE,theOffset,theTokenizer.mLength);
+ if(kNotFound!=theMLTagPos) {
+ aDocType=eXHTMLText;
+ if(IsLoosePI(aBuffer,theMLTagPos+4,20))
+ thePublicID=eDTDMode_transitional;
+ else thePublicID=eDTDMode_strict;
+ }
+
+ else {
+
+ //now check for strict ISO/IEC OWNER...
+ if(kNotFound!=aBuffer.Find("15445:1999",PR_FALSE,theOffset,theDTDPos-theTokenizer.mOffset)) {
+ thePublicID=eDTDMode_strict; //this ISO/IEC DTD is always strict.
+ aDocType=eHTML4Text;
+ }
+
+ else {
+
+ //for W3C DTD's, let's make sure it's HTML...
+ PRInt32 theMLTagPos=aBuffer.Find("HTML",PR_TRUE,theOffset,theTokenizer.mLength);
+ if(kNotFound==theMLTagPos) {
+ theMLTagPos=aBuffer.Find("HYPERTEXT MARKUP",PR_TRUE,theOffset,theTokenizer.mLength);
+ }
+
+ if(kNotFound!=theMLTagPos) {
+ //and now check the version number...
+
+ PRInt32 theVersionPos=aBuffer.FindCharInSet("1234567890",theMLTagPos);
+ PRInt32 theMajorVersion=3;
+
+ if((0<=theVersionPos) && (theVersionPos",theVersionPos+1);
+ if(theTerminal) {
+ aBuffer.Mid(theNum,theVersionPos,theTerminal-theVersionPos);
+ }
+ else aBuffer.Mid(theNum,theVersionPos,3);
+ PRInt32 theErr=0;
+ theMajorVersion=theNum.ToInteger(&theErr);
+
+ if((0==theErr) && (310) done=PR_TRUE; //prevent infinite loops...
+ } //while
+
+
+ if(theSystemID==thePublicID)
+ aParseMode=thePublicID;
+ else if(eDTDMode_unknown==theSystemID){
+ aParseMode=thePublicID;
+ if(eHTML4Text==aDocType) {
+ if (eDTDMode_transitional==thePublicID)
+ aParseMode=eDTDMode_quirks; //degrade because the systemID is missing.
+ }
+ }
+ else {
+ //ack! The doctype is badly formed (system and public ID's contradict).
+ //let's switch back to default compatibility mode...
+ aParseMode=eDTDMode_unknown;
+ }
+ }
+ }
+
+ if(eDTDMode_unknown==aParseMode) {
+ //nothing left to do but fail gracefully...
+ if(eXHTMLText==aDocType) {
+ aParseMode=eDTDMode_transitional;
+ }
+ if(eHTML4Text==aDocType) {
+ aDocType=eHTML3Text;
+ aParseMode=eDTDMode_quirks;
+ }
+ }
+
+#ifdef DISABLE_TRANSITIONAL_MODE
+
+ /********************************************************************************************
+ The following code is here because to deal with a nasty backward compatibility problem.
+ The composer product emits for the documents it creates,
+ but the documents aren't really compliant. To prevent lots of pages from breaking, well
+ disable proper handling of Transitional doctypes and use quirks mode instead. If lucky,
+ we'll get to add a pref to allow power users to get the right answer.
+ ********************************************************************************************/
+
+ if(eDTDMode_transitional==aParseMode) {
+ if(eHTML4Text==aDocType)
+ aParseMode=eDTDMode_quirks;
+ else if(eXHTMLText==aDocType)
+ aParseMode=eDTDMode_strict;
+ }
+#endif
+
+
+}
+
/**
* This is called when it's time to find out
* what mode the parser/DTD should run for this document.
@@ -512,16 +850,17 @@ nsDTDMode nsParser::GetParseMode(void){
* @return parsermode (define in nsIParser.h)
*/
static
-void DetermineParseMode(nsString& aBuffer,nsDTDMode& aParseMode,eParserDocType& aDocType,const nsString& aMimeType) {
+void DetermineParseMode2(nsString& aBuffer,nsDTDMode& aParseMode,eParserDocType& aDocType,const nsString& aMimeType) {
const char* theModeStr= PR_GetEnv("PARSE_MODE");
aParseMode = eDTDMode_unknown;
-
+
+ PRInt32 theGTPos=aBuffer.FindChar(kGreaterThan);
+
PRInt32 theIndex=aBuffer.Find("DOCTYPE",PR_TRUE,0,100);
if(kNotFound'
- PRInt32 theGTPos=aBuffer.FindChar(kGreaterThan,theIndex+1);
PRInt32 theEnd=(kNotFound==theGTPos) ? 512 : MinInt(512,theGTPos);
PRInt32 theSubIndex=aBuffer.Find("//DTD",PR_TRUE,theIndex+8,theEnd-(theIndex+8)); //skip to the type and desc-text...
PRInt32 theErr=0;
@@ -552,6 +891,8 @@ void DetermineParseMode(nsString& aBuffer,nsDTDMode& aParseMode,eParserDocType&
if(kNotFound",
- "",
- "",
+ //here are the XHTML doctypes we'll treat accordingly...
- "",
- "",
- "",
+ "",
+ "",
+ "",
//here are a few HTML doctypes we'll treat as strict...
- "",
"",
+ "",
+ "",
"",
-
- "",
- "",
+ "",
"",
"",
@@ -888,17 +1226,13 @@ static const char* doctypes[] = {
"",
"",
- "",
"",
- //here are the XHTML doctypes we'll treat as strict...
- "",
- "",
- "",
- //these we treat as compatible (no quirks if possible)...
+ //these we treat as transitional (unless it's disabled)...
- "",
+ "",
+ "",
"",
"",
"",
@@ -910,6 +1244,11 @@ static const char* doctypes[] = {
"",
//these we treat as compatible with quirks... (along with any other we encounter)...
+
+ "",
+ "",
+ "",
+ "",
"",
"",
"",
@@ -925,7 +1264,6 @@ static const char* doctypes[] = {
"",
"",
"",
- "",
"",
"",
@@ -1021,22 +1359,6 @@ nsresult nsParser::WillBuildModel(nsString& aFilename){
nsString& theBuffer=mParserContext->mScanner->GetBuffer();
DetermineParseMode(theBuffer,mParserContext->mDTDMode,mParserContext->mDocType,mParserContext->mMimeType);
-#define DISABLE_TRANSITIONAL_MODE
-#ifdef DISABLE_TRANSITIONAL_MODE
-
- /********************************************************************************************
- The following code is here because to deal with a nasty backward compatibility problem.
- The composer product emits for the documents it creates,
- but the documents aren't really compliant. To prevent lots of pages from breaking, well
- disable proper handling of Transitional doctypes and use quirks mode instead. If lucky,
- we'll get to add a pref to allow power users to get the right answer.
- ********************************************************************************************/
-
- if(eDTDMode_transitional==mParserContext->mDTDMode) {
- mParserContext->mDTDMode=eDTDMode_quirks;
- }
-#endif
-
if(PR_TRUE==FindSuitableDTD(*mParserContext,theBuffer)) {
mParserContext->mDTD->WillBuildModel( *mParserContext,mSink);
}//if
diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp
index ef935e3ad6f..7003d5dfae8 100644
--- a/mozilla/parser/htmlparser/src/nsParser.cpp
+++ b/mozilla/parser/htmlparser/src/nsParser.cpp
@@ -24,6 +24,8 @@
#define DEBUG_XMLENCODING
#define XMLENCODING_PEEKBYTES 64
//#define TEST_DOCTYPES
+//#define DISABLE_TRANSITIONAL_MODE
+
#include "nsParser.h"
#include "nsIContentSink.h"
@@ -466,6 +468,108 @@ nsDTDMode nsParser::GetParseMode(void){
}
+
+class CWordTokenizer {
+public:
+ CWordTokenizer(nsString& aString,PRInt32 aStartOffset,PRInt32 aMaxOffset) {
+ mLength=0;
+ mOffset=aStartOffset;
+ mMaxOffset=aMaxOffset;
+ mBuffer=aString.GetUnicode();
+ mEndBuffer=mBuffer+mMaxOffset;
+ }
+
+ //********************************************************************************
+ // Get offset of nth word in string.
+ // We define words as:
+ // 1) sequence of alphanum;
+ // 2) quoted substring
+ // 3) SGML comment -- ... --
+ // Returns offset of nth word, or -1 (if out of words).
+ //********************************************************************************
+
+ PRInt32 GetNextWord() {
+
+ const PRUnichar *cp=mBuffer+mOffset+mLength; //skip last word
+
+ mLength=0; //reset this
+ mOffset=-1; //reset this
+
+ //now skip whitespace...
+
+ PRUnichar target=0;
+ PRBool done=PR_FALSE;
+
+ while((!done) && (cp++
- [HTML] [PUBLIC|...] [+|-] [W3C|IETF|...] [DTD] "..." [EN]|...] "..."
+ [HTML] [PUBLIC|SYTEM] [+|-] [W3C|IETF|...] [DTD] "..." [EN]|...] "..."
Here are the new rules for DTD handling; comments welcome:
@@ -502,7 +606,241 @@ nsDTDMode nsParser::GetParseMode(void){
All other doctypes (<4.0), and documents without a doctype are handled in compatibility-mode.
*****************************************************************************************************/
-
+
+static
+PRBool IsLoosePI(nsString& aBuffer,PRInt32 anOffset,PRInt32 aCount) {
+ PRBool result=PR_FALSE;
+
+ if((aBuffer.Find("TRANSITIONAL",PR_TRUE,anOffset,aCount)>kNotFound)||
+ (aBuffer.Find("LOOSE",PR_TRUE,anOffset,aCount)>kNotFound) ||
+ (aBuffer.Find("FRAMESET",PR_TRUE,anOffset,aCount)>kNotFound) ||
+ (aBuffer.Find("LATIN1", PR_TRUE,anOffset,aCount) >kNotFound) ||
+ (aBuffer.Find("SYMBOLS",PR_TRUE,anOffset,aCount) >kNotFound) ||
+ (aBuffer.Find("SPECIAL",PR_TRUE,anOffset,aCount) >kNotFound)) {
+
+ result=PR_TRUE;
+
+ }
+ return result;
+}
+
+/**
+ * This is called when it's time to find out
+ * what mode the parser/DTD should run for this document.
+ * (Each parsercontext can have it's own mode).
+ *
+ * @update gess 06/24/00
+ * @return parsermode (define in nsIParser.h)
+ */
+static
+void DetermineParseMode(nsString& aBuffer,nsDTDMode& aParseMode,eParserDocType& aDocType,const nsString& aMimeType) {
+ const char* theModeStr= PR_GetEnv("PARSE_MODE");
+
+ aParseMode=eDTDMode_quirks;
+ aDocType=eHTML3Text;
+
+
+ //let's eliminate non-HTML as quickly as possible...
+
+ PRInt32 theIndex=aBuffer.Find("?XML",PR_TRUE,0,128);
+ if(kNotFound!=theIndex) {
+ aParseMode=eDTDMode_strict;
+ if(aMimeType.EqualsWithConversion(kHTMLTextContentType)) {
+ //this is here to prevent a crash if someone gives us an XML document,
+ //but necko tells us it's a text/html mimetype.
+ aDocType=eHTML4Text;
+ aParseMode=eDTDMode_strict;
+ }
+ else aDocType=eXMLText;
+ return;
+
+ }
+ else if(aMimeType.EqualsWithConversion(kPlainTextContentType)) {
+ aDocType=ePlainText;
+ aParseMode=eDTDMode_quirks;
+ return;
+ }
+ else if(aMimeType.EqualsWithConversion(kRTFTextContentType)) {
+ aDocType=ePlainText;
+ aParseMode=eDTDMode_quirks;
+ return;
+ }
+
+
+ //now let's see if we have HTML or XHTML...
+
+ PRInt32 theGTPos=aBuffer.FindChar(kGreaterThan);
+
+ if(kNotFound!=theGTPos) {
+
+ const PRUnichar* theBuffer=aBuffer.GetUnicode();
+ CWordTokenizer theTokenizer(aBuffer,1,theGTPos);
+ PRInt32 theOffset=theTokenizer.GetNextWord(); //try to find ?xml, !doctype, etc...
+
+ if((kNotFound!=theOffset) &&
+ (0==nsCRT::strncasecmp(theBuffer+theOffset,"DOCTYPE",theTokenizer.mLength))) {
+
+ //Ok -- so assume it's (X)HTML; now figure out the flavor...
+
+ PRInt32 theIter=0; //prevent infinite loops...
+ PRBool done=PR_FALSE; //use this to quit if we find garbage...
+ PRBool readSystemID=PR_FALSE;
+ nsDTDMode thePublicID=eDTDMode_quirks;
+ nsDTDMode theSystemID=eDTDMode_unknown;
+
+ theOffset=theTokenizer.GetNextWord();
+
+ while((kNotFound!=theOffset) && (!done)) {
+
+ PRUnichar theChar=*(theBuffer+theTokenizer.mOffset);
+ if(kQuote==theChar) {
+
+ if(readSystemID) {
+
+ PRInt32 thePrefix=aBuffer.Find("http://www.w3.org/tr/",PR_TRUE,theOffset,5); //find the prefix
+
+ if(kNotFound!=thePrefix) {
+ thePrefix+=20;
+ if(IsLoosePI(aBuffer,thePrefix,25)) { //find loose.dtd
+ theSystemID=eDTDMode_transitional;
+ }
+ else if(kNotFound!=aBuffer.Find("strict.dtd",PR_TRUE,thePrefix,25)) { //find strict.dtd
+ theSystemID=eDTDMode_strict;
+ }
+ }
+
+ }
+
+ else { //the public ID...
+
+ readSystemID=PR_TRUE;
+
+ PRInt32 theDTDPos=aBuffer.Find("//DTD",PR_TRUE,theOffset,theTokenizer.mLength);
+ if(theDTDPos) {
+
+ //first, let's see if it's XHML...
+ PRInt32 theMLTagPos=aBuffer.Find("XHTML",PR_TRUE,theOffset,theTokenizer.mLength);
+ if(kNotFound!=theMLTagPos) {
+ aDocType=eXHTMLText;
+ if(IsLoosePI(aBuffer,theMLTagPos+4,20))
+ thePublicID=eDTDMode_transitional;
+ else thePublicID=eDTDMode_strict;
+ }
+
+ else {
+
+ //now check for strict ISO/IEC OWNER...
+ if(kNotFound!=aBuffer.Find("15445:1999",PR_FALSE,theOffset,theDTDPos-theTokenizer.mOffset)) {
+ thePublicID=eDTDMode_strict; //this ISO/IEC DTD is always strict.
+ aDocType=eHTML4Text;
+ }
+
+ else {
+
+ //for W3C DTD's, let's make sure it's HTML...
+ PRInt32 theMLTagPos=aBuffer.Find("HTML",PR_TRUE,theOffset,theTokenizer.mLength);
+ if(kNotFound==theMLTagPos) {
+ theMLTagPos=aBuffer.Find("HYPERTEXT MARKUP",PR_TRUE,theOffset,theTokenizer.mLength);
+ }
+
+ if(kNotFound!=theMLTagPos) {
+ //and now check the version number...
+
+ PRInt32 theVersionPos=aBuffer.FindCharInSet("1234567890",theMLTagPos);
+ PRInt32 theMajorVersion=3;
+
+ if((0<=theVersionPos) && (theVersionPos",theVersionPos+1);
+ if(theTerminal) {
+ aBuffer.Mid(theNum,theVersionPos,theTerminal-theVersionPos);
+ }
+ else aBuffer.Mid(theNum,theVersionPos,3);
+ PRInt32 theErr=0;
+ theMajorVersion=theNum.ToInteger(&theErr);
+
+ if((0==theErr) && (310) done=PR_TRUE; //prevent infinite loops...
+ } //while
+
+
+ if(theSystemID==thePublicID)
+ aParseMode=thePublicID;
+ else if(eDTDMode_unknown==theSystemID){
+ aParseMode=thePublicID;
+ if(eHTML4Text==aDocType) {
+ if (eDTDMode_transitional==thePublicID)
+ aParseMode=eDTDMode_quirks; //degrade because the systemID is missing.
+ }
+ }
+ else {
+ //ack! The doctype is badly formed (system and public ID's contradict).
+ //let's switch back to default compatibility mode...
+ aParseMode=eDTDMode_unknown;
+ }
+ }
+ }
+
+ if(eDTDMode_unknown==aParseMode) {
+ //nothing left to do but fail gracefully...
+ if(eXHTMLText==aDocType) {
+ aParseMode=eDTDMode_transitional;
+ }
+ if(eHTML4Text==aDocType) {
+ aDocType=eHTML3Text;
+ aParseMode=eDTDMode_quirks;
+ }
+ }
+
+#ifdef DISABLE_TRANSITIONAL_MODE
+
+ /********************************************************************************************
+ The following code is here because to deal with a nasty backward compatibility problem.
+ The composer product emits for the documents it creates,
+ but the documents aren't really compliant. To prevent lots of pages from breaking, well
+ disable proper handling of Transitional doctypes and use quirks mode instead. If lucky,
+ we'll get to add a pref to allow power users to get the right answer.
+ ********************************************************************************************/
+
+ if(eDTDMode_transitional==aParseMode) {
+ if(eHTML4Text==aDocType)
+ aParseMode=eDTDMode_quirks;
+ else if(eXHTMLText==aDocType)
+ aParseMode=eDTDMode_strict;
+ }
+#endif
+
+
+}
+
/**
* This is called when it's time to find out
* what mode the parser/DTD should run for this document.
@@ -512,16 +850,17 @@ nsDTDMode nsParser::GetParseMode(void){
* @return parsermode (define in nsIParser.h)
*/
static
-void DetermineParseMode(nsString& aBuffer,nsDTDMode& aParseMode,eParserDocType& aDocType,const nsString& aMimeType) {
+void DetermineParseMode2(nsString& aBuffer,nsDTDMode& aParseMode,eParserDocType& aDocType,const nsString& aMimeType) {
const char* theModeStr= PR_GetEnv("PARSE_MODE");
aParseMode = eDTDMode_unknown;
-
+
+ PRInt32 theGTPos=aBuffer.FindChar(kGreaterThan);
+
PRInt32 theIndex=aBuffer.Find("DOCTYPE",PR_TRUE,0,100);
if(kNotFound'
- PRInt32 theGTPos=aBuffer.FindChar(kGreaterThan,theIndex+1);
PRInt32 theEnd=(kNotFound==theGTPos) ? 512 : MinInt(512,theGTPos);
PRInt32 theSubIndex=aBuffer.Find("//DTD",PR_TRUE,theIndex+8,theEnd-(theIndex+8)); //skip to the type and desc-text...
PRInt32 theErr=0;
@@ -552,6 +891,8 @@ void DetermineParseMode(nsString& aBuffer,nsDTDMode& aParseMode,eParserDocType&
if(kNotFound",
- "",
- "",
+ //here are the XHTML doctypes we'll treat accordingly...
- "",
- "",
- "",
+ "",
+ "",
+ "",
//here are a few HTML doctypes we'll treat as strict...
- "",
"",
+ "",
+ "",
"",
-
- "",
- "",
+ "",
"",
"",
@@ -888,17 +1226,13 @@ static const char* doctypes[] = {
"",
"",
- "",
"",
- //here are the XHTML doctypes we'll treat as strict...
- "",
- "",
- "",
- //these we treat as compatible (no quirks if possible)...
+ //these we treat as transitional (unless it's disabled)...
- "",
+ "",
+ "",
"",
"",
"",
@@ -910,6 +1244,11 @@ static const char* doctypes[] = {
"",
//these we treat as compatible with quirks... (along with any other we encounter)...
+
+ "",
+ "",
+ "",
+ "",
"",
"",
"",
@@ -925,7 +1264,6 @@ static const char* doctypes[] = {
"",
"",
"",
- "",
"",
"",
@@ -1021,22 +1359,6 @@ nsresult nsParser::WillBuildModel(nsString& aFilename){
nsString& theBuffer=mParserContext->mScanner->GetBuffer();
DetermineParseMode(theBuffer,mParserContext->mDTDMode,mParserContext->mDocType,mParserContext->mMimeType);
-#define DISABLE_TRANSITIONAL_MODE
-#ifdef DISABLE_TRANSITIONAL_MODE
-
- /********************************************************************************************
- The following code is here because to deal with a nasty backward compatibility problem.
- The composer product emits for the documents it creates,
- but the documents aren't really compliant. To prevent lots of pages from breaking, well
- disable proper handling of Transitional doctypes and use quirks mode instead. If lucky,
- we'll get to add a pref to allow power users to get the right answer.
- ********************************************************************************************/
-
- if(eDTDMode_transitional==mParserContext->mDTDMode) {
- mParserContext->mDTDMode=eDTDMode_quirks;
- }
-#endif
-
if(PR_TRUE==FindSuitableDTD(*mParserContext,theBuffer)) {
mParserContext->mDTD->WillBuildModel( *mParserContext,mSink);
}//if