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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 2117213003: Duplicate payment method identifiers in methodData and details.modififiers should throw TypeError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
Index: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
index e3da8a51339833091acfc3cae2bc2ca25a1ecf31..2c5983de3ba29908cd09bc38f19e2d1a2ad32fa9 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -224,10 +224,19 @@ void validatePaymentDetailsModifiers(const HeapVector<PaymentDetailsModifier>& m
return;
}
+ HashSet<String> uniqueMethods;
for (const auto& modifier : modifiers) {
if (modifier.supportedMethods().isEmpty()) {
exceptionState.throwTypeError("Must specify at least one payment method identifier");
return;
+ } else {
please use gerrit instead 2016/07/06 07:31:56 No need for "else", because the previous clause re
pals 2016/07/07 05:14:13 Done.
+ for (const auto& method : modifier.supportedMethods()) {
+ if (uniqueMethods.contains(method)) {
+ exceptionState.throwTypeError("Duplicate payment method identifiers are not allowed");
+ return;
+ }
+ uniqueMethods.add(method);
+ }
}
if (modifier.hasTotal()) {
@@ -289,10 +298,19 @@ void validateAndConvertPaymentMethodData(const HeapVector<PaymentMethodData>& pa
return;
}
+ HashSet<String> uniqueMethods;
for (const auto& pmd : paymentMethodData) {
if (pmd.supportedMethods().isEmpty()) {
exceptionState.throwTypeError("Must specify at least one payment method identifier");
return;
+ } else {
please use gerrit instead 2016/07/06 07:31:56 Ditto.
pals 2016/07/07 05:14:13 Done.
+ for (const auto& method : pmd.supportedMethods()) {
+ if (uniqueMethods.contains(method)) {
+ exceptionState.throwTypeError("Duplicate payment method identifiers are not allowed");
+ return;
+ }
+ uniqueMethods.add(method);
+ }
}
String stringifiedData = "";

Powered by Google App Engine
This is Rietveld 408576698