diff --git a/mozilla/htmlparser/src/nsExpatTokenizer.cpp b/mozilla/htmlparser/src/nsExpatTokenizer.cpp
index e9923130a65..5fad29e7e20 100644
--- a/mozilla/htmlparser/src/nsExpatTokenizer.cpp
+++ b/mozilla/htmlparser/src/nsExpatTokenizer.cpp
@@ -133,6 +133,7 @@ void nsExpatTokenizer::SetupExpatCallbacks(void) {
nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
NS_INIT_REFCNT();
mBytesParsed = 0;
+ mSeenError = PR_FALSE;
mExpatParser = XML_ParserCreate(NULL);
gTokenRecycler=(CTokenRecycler*)GetTokenRecycler();
if (mExpatParser) {
@@ -148,8 +149,10 @@ nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
* @return
*/
nsExpatTokenizer::~nsExpatTokenizer(){
- if (mExpatParser)
- XML_ParserFree(mExpatParser);
+ if (mExpatParser) {
+ XML_ParserFree(mExpatParser);
+ mExpatParser = nsnull;
+ }
}
@@ -232,10 +235,13 @@ nsresult nsExpatTokenizer::ParseXMLBuffer(const char *aBuffer, PRUint32 aLength)
nsresult result=NS_OK;
if (mExpatParser) {
PR_ASSERT(aLength == strlen(aBuffer));
- if (!XML_Parse(mExpatParser, aBuffer, aLength, PR_FALSE)) {
- PushXMLErrorToken(aBuffer, aLength);
- }
- mBytesParsed += aLength;
+ if (!mSeenError) {
+ if (!XML_Parse(mExpatParser, aBuffer, aLength, PR_FALSE)) {
+ PushXMLErrorToken(aBuffer, aLength);
+ mSeenError = PR_TRUE;
+ }
+ mBytesParsed += aLength;
+ }
}
else {
result = NS_ERROR_FAILURE;
diff --git a/mozilla/htmlparser/src/nsExpatTokenizer.h b/mozilla/htmlparser/src/nsExpatTokenizer.h
index 386e7899a21..9c79b0e3d56 100644
--- a/mozilla/htmlparser/src/nsExpatTokenizer.h
+++ b/mozilla/htmlparser/src/nsExpatTokenizer.h
@@ -107,6 +107,7 @@ protected:
XML_Parser mExpatParser;
PRUint32 mBytesParsed;
+ PRBool mSeenError;
};
extern NS_HTMLPARS nsresult NS_Expat_Tokenizer(nsIDTD** aInstancePtrResult);
diff --git a/mozilla/htmlparser/src/nsWellFormedDTD.cpp b/mozilla/htmlparser/src/nsWellFormedDTD.cpp
index df174fb96c3..1833f7eb426 100644
--- a/mozilla/htmlparser/src/nsWellFormedDTD.cpp
+++ b/mozilla/htmlparser/src/nsWellFormedDTD.cpp
@@ -330,18 +330,18 @@ nsITokenRecycler* CWellFormedDTD::GetTokenRecycler(void){
*/
nsITokenizer* CWellFormedDTD::GetTokenizer(void) {
if(!mTokenizer) {
- PRBool theExpatState=PR_FALSE;
+ PRBool theExpatState=PR_TRUE;
#ifndef XP_MAC
- char* theEnvString = PR_GetEnv("EXPAT");
+ char* theEnvString = PR_GetEnv("NOEXPAT");
if(theEnvString){
if(('1'==theEnvString[0]) || ('Y'==theEnvString[0]) || ('y'==theEnvString[0])) {
- theExpatState=PR_TRUE; //this indicates that the EXPAT flag was found in the environment.
+ theExpatState=PR_FALSE; //this indicates that the EXPAT flag was found in the environment.
}
}
#else
// Check for the existence of a file called EXPAT in the current directory
nsSpecialSystemDirectory expatFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
- expatFile += "EXPAT";
+ expatFile += "NOEXPAT";
theExpatState = expatFile.Exists();
#endif
if(theExpatState) {
diff --git a/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp b/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp
index e9923130a65..5fad29e7e20 100644
--- a/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp
+++ b/mozilla/parser/htmlparser/src/nsExpatTokenizer.cpp
@@ -133,6 +133,7 @@ void nsExpatTokenizer::SetupExpatCallbacks(void) {
nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
NS_INIT_REFCNT();
mBytesParsed = 0;
+ mSeenError = PR_FALSE;
mExpatParser = XML_ParserCreate(NULL);
gTokenRecycler=(CTokenRecycler*)GetTokenRecycler();
if (mExpatParser) {
@@ -148,8 +149,10 @@ nsExpatTokenizer::nsExpatTokenizer() : nsHTMLTokenizer() {
* @return
*/
nsExpatTokenizer::~nsExpatTokenizer(){
- if (mExpatParser)
- XML_ParserFree(mExpatParser);
+ if (mExpatParser) {
+ XML_ParserFree(mExpatParser);
+ mExpatParser = nsnull;
+ }
}
@@ -232,10 +235,13 @@ nsresult nsExpatTokenizer::ParseXMLBuffer(const char *aBuffer, PRUint32 aLength)
nsresult result=NS_OK;
if (mExpatParser) {
PR_ASSERT(aLength == strlen(aBuffer));
- if (!XML_Parse(mExpatParser, aBuffer, aLength, PR_FALSE)) {
- PushXMLErrorToken(aBuffer, aLength);
- }
- mBytesParsed += aLength;
+ if (!mSeenError) {
+ if (!XML_Parse(mExpatParser, aBuffer, aLength, PR_FALSE)) {
+ PushXMLErrorToken(aBuffer, aLength);
+ mSeenError = PR_TRUE;
+ }
+ mBytesParsed += aLength;
+ }
}
else {
result = NS_ERROR_FAILURE;
diff --git a/mozilla/parser/htmlparser/src/nsExpatTokenizer.h b/mozilla/parser/htmlparser/src/nsExpatTokenizer.h
index 386e7899a21..9c79b0e3d56 100644
--- a/mozilla/parser/htmlparser/src/nsExpatTokenizer.h
+++ b/mozilla/parser/htmlparser/src/nsExpatTokenizer.h
@@ -107,6 +107,7 @@ protected:
XML_Parser mExpatParser;
PRUint32 mBytesParsed;
+ PRBool mSeenError;
};
extern NS_HTMLPARS nsresult NS_Expat_Tokenizer(nsIDTD** aInstancePtrResult);
diff --git a/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp b/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp
index df174fb96c3..1833f7eb426 100644
--- a/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp
+++ b/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp
@@ -330,18 +330,18 @@ nsITokenRecycler* CWellFormedDTD::GetTokenRecycler(void){
*/
nsITokenizer* CWellFormedDTD::GetTokenizer(void) {
if(!mTokenizer) {
- PRBool theExpatState=PR_FALSE;
+ PRBool theExpatState=PR_TRUE;
#ifndef XP_MAC
- char* theEnvString = PR_GetEnv("EXPAT");
+ char* theEnvString = PR_GetEnv("NOEXPAT");
if(theEnvString){
if(('1'==theEnvString[0]) || ('Y'==theEnvString[0]) || ('y'==theEnvString[0])) {
- theExpatState=PR_TRUE; //this indicates that the EXPAT flag was found in the environment.
+ theExpatState=PR_FALSE; //this indicates that the EXPAT flag was found in the environment.
}
}
#else
// Check for the existence of a file called EXPAT in the current directory
nsSpecialSystemDirectory expatFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
- expatFile += "EXPAT";
+ expatFile += "NOEXPAT";
theExpatState = expatFile.Exists();
#endif
if(theExpatState) {