diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index 9dc5c117f4f..8ef76d0d5a6 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -603,6 +603,8 @@ nsHTMLInputElement::SetSize(PRUint32 aValue) NS_IMETHODIMP nsHTMLInputElement::GetValue(nsAString& aValue) { + static const char* kWhitespace = "\n\r\t\b"; + if (mType == NS_FORM_INPUT_TEXT || mType == NS_FORM_INPUT_PASSWORD || mType == NS_FORM_INPUT_FILE) { // No need to flush here, if there's no frame created for this @@ -631,6 +633,9 @@ nsHTMLInputElement::GetValue(nsAString& aValue) } else { CopyUTF8toUTF16(mValue, aValue); } + + // Bug 114997: trim \n, etc. for non-hidden inputs + aValue = nsContentUtils::TrimCharsInSet(kWhitespace, aValue); } return NS_OK; @@ -643,6 +648,10 @@ nsHTMLInputElement::GetValue(nsAString& aValue) aValue.AssignLiteral("on"); } + if (mType != NS_FORM_INPUT_HIDDEN) { + aValue = nsContentUtils::TrimCharsInSet(kWhitespace, aValue); + } + return NS_OK; } diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 3d35816d8a0..e047d330e82 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -839,8 +839,15 @@ HTMLContentSink::AddAttributes(const nsIParserNode& aNode, // Get value and remove mandatory quotes static const char* kWhitespace = "\n\r\t\b"; + + // Bug 114997: Don't trim whitespace on : + // Using ?: outside the function call would be more efficient, but + // we don't trust ?: with references. const nsAString& v = - nsContentUtils::TrimCharsInSet(kWhitespace, aNode.GetValueAt(i)); + nsContentUtils::TrimCharsInSet( + (nodeType == eHTMLTag_input && + keyAtom == nsHTMLAtoms::value) ? + "" : kWhitespace, aNode.GetValueAt(i)); if (nodeType == eHTMLTag_a && keyAtom == nsHTMLAtoms::name) { NS_ConvertUTF16toUTF8 cname(v);