Title: [202341] trunk/Source/WebCore
Revision
202341
Author
[email protected]
Date
2016-06-22 11:43:18 -0700 (Wed, 22 Jun 2016)

Log Message

Exception is not thrown when shipping method is an invalid amount
https://bugs.webkit.org/show_bug.cgi?id=159029
rdar://problem/26700413

Reviewed by Tim Horton.

* Modules/applepay/PaymentRequest.h:
Change ShippingMethod::amount to be a signed 64-bit integer.

* Modules/applepay/PaymentRequestValidator.cpp:
(WebCore::PaymentRequestValidator::validate):
Call validateShippingMethods.

(WebCore::PaymentRequestValidator::validateShippingMethods):
Validate all the shipping methods.

(WebCore::PaymentRequestValidator::validateShippingMethod):
Check that the amount is >= 0.

* Modules/applepay/PaymentRequestValidator.h:
Add new members.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (202340 => 202341)


--- trunk/Source/WebCore/ChangeLog	2016-06-22 18:20:31 UTC (rev 202340)
+++ trunk/Source/WebCore/ChangeLog	2016-06-22 18:43:18 UTC (rev 202341)
@@ -1,3 +1,27 @@
+2016-06-22  Anders Carlsson  <[email protected]>
+
+        Exception is not thrown when shipping method is an invalid amount
+        https://bugs.webkit.org/show_bug.cgi?id=159029
+        rdar://problem/26700413
+
+        Reviewed by Tim Horton.
+
+        * Modules/applepay/PaymentRequest.h:
+        Change ShippingMethod::amount to be a signed 64-bit integer.
+
+        * Modules/applepay/PaymentRequestValidator.cpp:
+        (WebCore::PaymentRequestValidator::validate):
+        Call validateShippingMethods.
+
+        (WebCore::PaymentRequestValidator::validateShippingMethods):
+        Validate all the shipping methods.
+
+        (WebCore::PaymentRequestValidator::validateShippingMethod):
+        Check that the amount is >= 0.
+
+        * Modules/applepay/PaymentRequestValidator.h:
+        Add new members.
+
 2016-06-22  Adam Bergkvist  <[email protected]>
 
         WebRTC: Add support for the negotiationneeded event in MediaEndpointPeerConnection

Modified: trunk/Source/WebCore/Modules/applepay/PaymentRequest.h (202340 => 202341)


--- trunk/Source/WebCore/Modules/applepay/PaymentRequest.h	2016-06-22 18:20:31 UTC (rev 202340)
+++ trunk/Source/WebCore/Modules/applepay/PaymentRequest.h	2016-06-22 18:43:18 UTC (rev 202341)
@@ -112,7 +112,7 @@
     struct ShippingMethod {
         String label;
         String detail;
-        uint64_t amount;
+        int64_t amount;
 
         String identifier;
     };

Modified: trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp (202340 => 202341)


--- trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp	2016-06-22 18:20:31 UTC (rev 202340)
+++ trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp	2016-06-22 18:43:18 UTC (rev 202341)
@@ -57,7 +57,8 @@
         return false;
     if (!validateTotal(paymentRequest.total()))
         return false;
-
+    if (!validateShippingMethods(paymentRequest.shippingMethods()))
+        return false;
     return true;
 }
 
@@ -136,6 +137,16 @@
     return true;
 }
 
+bool PaymentRequestValidator::validateShippingMethod(const PaymentRequest::ShippingMethod& shippingMethod) const
+{
+    if (shippingMethod.amount < 0) {
+        m_window.printErrorMessage("Shipping method amount must be greater than or equal to zero.");
+        return false;
+    }
+
+    return true;
+}
+
 bool PaymentRequestValidator::validateSupportedNetworks(const PaymentRequest::SupportedNetworks& supportedNetworks) const
 {
     if (!supportedNetworks.amex && !supportedNetworks.chinaUnionPay && !supportedNetworks.discover && !supportedNetworks.interac && !supportedNetworks.masterCard && !supportedNetworks.privateLabel &&!supportedNetworks.visa) {
@@ -146,6 +157,16 @@
     return true;
 }
 
+bool PaymentRequestValidator::validateShippingMethods(const Vector<PaymentRequest::ShippingMethod>& shippingMethods) const
+{
+    for (const auto& shippingMethod : shippingMethods) {
+        if (!validateShippingMethod(shippingMethod))
+            return false;
+    }
+
+    return true;
 }
 
+}
+
 #endif

Modified: trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.h (202340 => 202341)


--- trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.h	2016-06-22 18:20:31 UTC (rev 202340)
+++ trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.h	2016-06-22 18:43:18 UTC (rev 202341)
@@ -47,6 +47,9 @@
     bool validateMerchantCapabilities(const PaymentRequest::MerchantCapabilities&) const;
     bool validateSupportedNetworks(const PaymentRequest::SupportedNetworks&) const;
 
+    bool validateShippingMethods(const Vector<PaymentRequest::ShippingMethod>&) const;
+    bool validateShippingMethod(const PaymentRequest::ShippingMethod&) const;
+
     DOMWindow& m_window;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to