diff --git a/mozilla/htmlparser/src/CNavDTD.cpp b/mozilla/htmlparser/src/CNavDTD.cpp
index 1bbb9248abe..cea970cb7b3 100644
--- a/mozilla/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/htmlparser/src/CNavDTD.cpp
@@ -1691,6 +1691,13 @@ nsresult CNavDTD::CollectAttributes(nsCParserNode& aNode,eHTMLTags aTag,PRInt32
theToken=(CToken*)mSkippedContent.PopFront();
else theToken=mTokenizer->PopToken();
if(theToken) {
+ CAttributeToken* theAttrToken = ((CAttributeToken*)theToken);
+ nsString& key=theAttrToken->GetKey();
+ // Sanitize the key for it might contain some non-alpha-non-digit characters
+ // at its end. Ex. - This will be tokenized as "<" "OPTION",
+ // "SELECTED/", and ">". In this case the "SELECTED/" key will be sanitized to
+ // a legitimate "SELECTED" key.
+ theAttrToken->Sanitize(key);
#ifdef RICKG_DEBUG
WriteTokenToLog(theToken);
diff --git a/mozilla/htmlparser/src/nsHTMLTokens.cpp b/mozilla/htmlparser/src/nsHTMLTokens.cpp
index fb3999d2597..fa67f63fc02 100644
--- a/mozilla/htmlparser/src/nsHTMLTokens.cpp
+++ b/mozilla/htmlparser/src/nsHTMLTokens.cpp
@@ -1046,6 +1046,27 @@ PRInt32 CAttributeToken::GetTokenType(void) {
return eToken_attribute;
}
+/*
+ * Removes non-alpha-non-digit characters from the end of the string
+ *
+ * @update harishd 07/15/99
+ * @param aString - The string might contain garbage at the end!!
+ * @return
+ */
+void CAttributeToken::Sanitize(nsString& aString) {
+ PRInt32 length=aString.Length();
+ if(length > 0) {
+ PRUnichar theChar=aString.Last();
+ while(!nsString::IsAlpha(theChar) && !nsString::IsDigit(theChar)) {
+ aString.Truncate(length-1);
+ length = aString.Length();
+ if(length <= 0) break;
+ theChar = aString.Last();
+ }
+ }
+ return;
+}
+
/*
* Dump contents of this token to given output stream
*
diff --git a/mozilla/htmlparser/src/nsHTMLTokens.h b/mozilla/htmlparser/src/nsHTMLTokens.h
index 06e6c4df3fa..77767bfd767 100644
--- a/mozilla/htmlparser/src/nsHTMLTokens.h
+++ b/mozilla/htmlparser/src/nsHTMLTokens.h
@@ -262,6 +262,7 @@ class CAttributeToken: public CHTMLToken {
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual nsString& GetKey(void) {return mTextKey;}
+ virtual void Sanitize(nsString& aString);
virtual void DebugDumpToken(ostream& out);
virtual void GetSource(nsString& anOutputString);
virtual void DebugDumpSource(ostream& out);
diff --git a/mozilla/parser/htmlparser/src/CNavDTD.cpp b/mozilla/parser/htmlparser/src/CNavDTD.cpp
index 1bbb9248abe..cea970cb7b3 100644
--- a/mozilla/parser/htmlparser/src/CNavDTD.cpp
+++ b/mozilla/parser/htmlparser/src/CNavDTD.cpp
@@ -1691,6 +1691,13 @@ nsresult CNavDTD::CollectAttributes(nsCParserNode& aNode,eHTMLTags aTag,PRInt32
theToken=(CToken*)mSkippedContent.PopFront();
else theToken=mTokenizer->PopToken();
if(theToken) {
+ CAttributeToken* theAttrToken = ((CAttributeToken*)theToken);
+ nsString& key=theAttrToken->GetKey();
+ // Sanitize the key for it might contain some non-alpha-non-digit characters
+ // at its end. Ex. - This will be tokenized as "<" "OPTION",
+ // "SELECTED/", and ">". In this case the "SELECTED/" key will be sanitized to
+ // a legitimate "SELECTED" key.
+ theAttrToken->Sanitize(key);
#ifdef RICKG_DEBUG
WriteTokenToLog(theToken);
diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp
index fb3999d2597..fa67f63fc02 100644
--- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp
+++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp
@@ -1046,6 +1046,27 @@ PRInt32 CAttributeToken::GetTokenType(void) {
return eToken_attribute;
}
+/*
+ * Removes non-alpha-non-digit characters from the end of the string
+ *
+ * @update harishd 07/15/99
+ * @param aString - The string might contain garbage at the end!!
+ * @return
+ */
+void CAttributeToken::Sanitize(nsString& aString) {
+ PRInt32 length=aString.Length();
+ if(length > 0) {
+ PRUnichar theChar=aString.Last();
+ while(!nsString::IsAlpha(theChar) && !nsString::IsDigit(theChar)) {
+ aString.Truncate(length-1);
+ length = aString.Length();
+ if(length <= 0) break;
+ theChar = aString.Last();
+ }
+ }
+ return;
+}
+
/*
* Dump contents of this token to given output stream
*
diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.h b/mozilla/parser/htmlparser/src/nsHTMLTokens.h
index 06e6c4df3fa..77767bfd767 100644
--- a/mozilla/parser/htmlparser/src/nsHTMLTokens.h
+++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.h
@@ -262,6 +262,7 @@ class CAttributeToken: public CHTMLToken {
virtual const char* GetClassName(void);
virtual PRInt32 GetTokenType(void);
virtual nsString& GetKey(void) {return mTextKey;}
+ virtual void Sanitize(nsString& aString);
virtual void DebugDumpToken(ostream& out);
virtual void GetSource(nsString& anOutputString);
virtual void DebugDumpSource(ostream& out);