Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(674)

Unified Diff: Source/core/html/HTMLTextAreaElement.cpp

Issue 656683005: Use parseHTMLInteger for parsing minlength and maxlength in <textarea> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add layout tests that check for leading non-ASCII whitespaces in min/maxlength attribute Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/forms/textarea-minlength-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLTextAreaElement.cpp
diff --git a/Source/core/html/HTMLTextAreaElement.cpp b/Source/core/html/HTMLTextAreaElement.cpp
index 40863e34fa78a496551e4670e735abb8c1b9d05d..dd8386955c609c0b935c397bab28f64a0aafa448 100644
--- a/Source/core/html/HTMLTextAreaElement.cpp
+++ b/Source/core/html/HTMLTextAreaElement.cpp
@@ -43,6 +43,7 @@
#include "core/frame/LocalFrame.h"
#include "core/html/FormDataList.h"
#include "core/html/forms/FormController.h"
+#include "core/html/parser/HTMLParserIdioms.h"
#include "core/html/shadow/ShadowElementNames.h"
#include "core/html/shadow/TextControlInnerElements.h"
#include "core/page/Chrome.h"
@@ -448,16 +449,18 @@ void HTMLTextAreaElement::setDefaultValue(const String& defaultValue)
int HTMLTextAreaElement::maxLength() const
{
- bool ok;
- int value = getAttribute(maxlengthAttr).toInt(&ok);
- return ok && value >= 0 ? value : -1;
+ int value;
+ if (!parseHTMLInteger(getAttribute(maxlengthAttr), value))
+ return -1;
+ return value >= 0 ? value : -1;
}
int HTMLTextAreaElement::minLength() const
{
- bool ok;
- int value = getAttribute(minlengthAttr).string().toInt(&ok);
- return ok && value >= 0 ? value : -1;
+ int value;
+ if (!parseHTMLInteger(getAttribute(minlengthAttr), value))
+ return -1;
+ return value >= 0 ? value : -1;
}
void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionState& exceptionState)
« no previous file with comments | « LayoutTests/fast/forms/textarea-minlength-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698