From 0518fff76056458a5d6d3c246ed459b0f2e8ed04 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sat, 24 Jan 2004 21:05:50 +0000 Subject: When checking forms for modifications, handle correctly text entries with 2004-01-24 Christian Persch * embed/mozilla/EphyBrowser.cpp: When checking forms for modifications, handle correctly text entries with default value longer than maxlength. Mozilla bug #232057. --- embed/mozilla/EphyBrowser.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'embed/mozilla/EphyBrowser.cpp') diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index 5f8657309..cd6d18f7c 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -900,7 +900,7 @@ nsresult EphyBrowser::GetDocumentHasModifiedForms (nsIDOMDocument *aDomDoc, PRUi /* Mozilla Bug 218277, 195946 and others */ default_text.ReplaceChar(0xa0, ' '); - if (Compare (user_text, default_text) != 0) + if (!user_text.Equals (default_text)) { *aHasTextArea = PR_TRUE; return NS_OK; @@ -918,13 +918,25 @@ nsresult EphyBrowser::GetDocumentHasModifiedForms (nsIDOMDocument *aDomDoc, PRUi if (type.EqualsIgnoreCase("text")) { nsAutoString default_text, user_text; + PRInt32 max_length; inputElement->GetDefaultValue (default_text); inputElement->GetValue (user_text); + inputElement->GetMaxLength (&max_length); + + /* Guard against arguably broken forms where + * default_text is longer than maxlength + * (user_text is cropped, default_text is not) + * Mozilla bug 232057 + */ + if (default_text.Length() > (PRUint32)max_length) + { + default_text.Truncate (max_length); + } /* Mozilla Bug 218277, 195946 and others */ default_text.ReplaceChar(0xa0, ' '); - if (Compare (user_text, default_text) != 0) + if (!user_text.Equals (default_text)) { (*aNumTextFields)++; if (*aNumTextFields >= NUM_MODIFIED_TEXTFIELDS_REQUIRED) -- cgit v1.2.3