Skip to content

Commit

Permalink
Backed out changeset 4b2b24f16463 (bug 1839572) for causing failures …
Browse files Browse the repository at this point in the history
…in HTMLInputElement.cpp a=backout
  • Loading branch information
dsmithpadilla committed Jul 20, 2023
1 parent e7c28b8 commit f5d631a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 54 deletions.
21 changes: 9 additions & 12 deletions dom/html/HTMLInputElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "mozilla/dom/FileSystemUtils.h"
#include "mozilla/dom/FormData.h"
#include "mozilla/dom/GetFilesHelper.h"
#include "mozilla/dom/NumericInputTypes.h"
#include "mozilla/dom/WindowContext.h"
#include "mozilla/dom/InputType.h"
#include "mozilla/dom/UserActivation.h"
Expand Down Expand Up @@ -1633,10 +1632,15 @@ void HTMLInputElement::SetValue(const nsAString& aValue, CallerType aCallerType,
// NOTE: this is currently quite expensive work (too much string
// manipulation). We should probably optimize that.
nsAutoString currentValue;
GetNonFileValueInternal(currentValue);
GetValue(currentValue, aCallerType);

// Some types sanitize value, so GetValue doesn't return pure
// previous value correctly.
//
// FIXME(emilio): Shouldn't above just use GetNonFileValueInternal() to
// get the unsanitized value?
nsresult rv = SetValueInternal(
aValue, &currentValue,
aValue, SanitizesOnValueGetter() ? nullptr : &currentValue,
{ValueSetterOption::ByContentAPI, ValueSetterOption::SetValueChanged,
ValueSetterOption::MoveCursorToEndIfValueChanged});
if (NS_FAILED(rv)) {
Expand Down Expand Up @@ -2641,14 +2645,7 @@ nsresult HTMLInputElement::SetValueInternal(
// prevent doing it if it's useless.
nsAutoString value(aValue);

if (mDoneCreating &&
!(mType == FormControlType::InputNumber &&
aOptions.contains(ValueSetterOption::BySetUserInputAPI))) {
// When the value of a number input is set by a script, we need to make
// sure the value is a valid floating-point number.
// https://html.spec.whatwg.org/#valid-floating-point-number
// When it's set by a user, however, we need to be more permissive, so
// we don't sanitize its value here. See bug 1839572.
if (mDoneCreating) {
SanitizeValue(value);
}
// else DoneCreatingElement calls us again once mDoneCreating is true
Expand Down Expand Up @@ -4589,7 +4586,7 @@ void HTMLInputElement::SanitizeValue(nsAString& aValue,
aValue);
} break;
case FormControlType::InputNumber: {
if (aKind == SanitizationKind::Other && !aValue.IsEmpty() &&
if (!aValue.IsEmpty() &&
(aValue.First() == '+' || aValue.Last() == '.')) {
// A value with a leading plus or trailing dot should fail to parse.
// However, the localized parser accepts this, and when we convert it
Expand Down

This file was deleted.

0 comments on commit f5d631a

Please sign in to comment.