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

Unified Diff: third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp

Issue 1745963002: CREDENTIAL: Do type checks for credential constructors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « third_party/WebKit/Source/modules/credentialmanager/FederatedCredential.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp
diff --git a/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp b/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp
index f539ccb5946f8053136b28c2f50309f45d448938..e174b504a68831f129717eaafeede9eca1c8c1d6 100644
--- a/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp
+++ b/third_party/WebKit/Source/modules/credentialmanager/PasswordCredential.cpp
@@ -25,9 +25,19 @@ PasswordCredential* PasswordCredential::create(WebPasswordCredential* webPasswor
PasswordCredential* PasswordCredential::create(const PasswordCredentialData& data, ExceptionState& exceptionState)
{
+ if (data.id().isEmpty()) {
+ exceptionState.throwTypeError("'id' must not be empty.");
+ return nullptr;
+ }
+ if (data.password().isEmpty()) {
+ exceptionState.throwTypeError("'password' must not be empty.");
+ return nullptr;
+ }
+
KURL iconURL = parseStringAsURL(data.iconURL(), exceptionState);
if (exceptionState.hadException())
return nullptr;
+
return new PasswordCredential(data.id(), data.password(), data.name(), iconURL);
}
« no previous file with comments | « third_party/WebKit/Source/modules/credentialmanager/FederatedCredential.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698