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

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: Review comments fixed 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
« no previous file with comments | « third_party/WebKit/LayoutTests/payments/payment-request-interface.html ('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/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..294efb8b5f8874240c440db7441eca8782220154 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -25,6 +25,7 @@
#include "mojo/public/cpp/bindings/wtf_array.h"
#include "platform/mojo/MojoHelper.h"
#include "public/platform/ServiceRegistry.h"
+#include "wtf/HashSet.h"
#include <utility>
namespace mojo {
@@ -224,11 +225,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;
}
+ 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()) {
validateShippingOptionOrPaymentItem(modifier.total(), exceptionState);
@@ -289,11 +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;
}
+ 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 = "";
if (pmd.hasData() && !pmd.data().isEmpty()) {
« no previous file with comments | « third_party/WebKit/LayoutTests/payments/payment-request-interface.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698