Changeset 202341 in webkit


Ignore:
Timestamp:
Jun 22, 2016 11:43:18 AM (8 years ago)
Author:
andersca@apple.com
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.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r202339 r202341  
     12016-06-22  Anders Carlsson  <andersca@apple.com>
     2
     3        Exception is not thrown when shipping method is an invalid amount
     4        https://bugs.webkit.org/show_bug.cgi?id=159029
     5        rdar://problem/26700413
     6
     7        Reviewed by Tim Horton.
     8
     9        * Modules/applepay/PaymentRequest.h:
     10        Change ShippingMethod::amount to be a signed 64-bit integer.
     11
     12        * Modules/applepay/PaymentRequestValidator.cpp:
     13        (WebCore::PaymentRequestValidator::validate):
     14        Call validateShippingMethods.
     15
     16        (WebCore::PaymentRequestValidator::validateShippingMethods):
     17        Validate all the shipping methods.
     18
     19        (WebCore::PaymentRequestValidator::validateShippingMethod):
     20        Check that the amount is >= 0.
     21
     22        * Modules/applepay/PaymentRequestValidator.h:
     23        Add new members.
     24
    1252016-06-22  Adam Bergkvist  <adam.bergkvist@ericsson.com>
    226
  • trunk/Source/WebCore/Modules/applepay/PaymentRequest.h

    r202298 r202341  
    113113        String label;
    114114        String detail;
    115         uint64_t amount;
     115        int64_t amount;
    116116
    117117        String identifier;
  • trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp

    r202309 r202341  
    5858    if (!validateTotal(paymentRequest.total()))
    5959        return false;
    60 
     60    if (!validateShippingMethods(paymentRequest.shippingMethods()))
     61        return false;
    6162    return true;
    6263}
     
    137138}
    138139
     140bool PaymentRequestValidator::validateShippingMethod(const PaymentRequest::ShippingMethod& shippingMethod) const
     141{
     142    if (shippingMethod.amount < 0) {
     143        m_window.printErrorMessage("Shipping method amount must be greater than or equal to zero.");
     144        return false;
     145    }
     146
     147    return true;
     148}
     149
    139150bool PaymentRequestValidator::validateSupportedNetworks(const PaymentRequest::SupportedNetworks& supportedNetworks) const
    140151{
     
    147158}
    148159
     160bool PaymentRequestValidator::validateShippingMethods(const Vector<PaymentRequest::ShippingMethod>& shippingMethods) const
     161{
     162    for (const auto& shippingMethod : shippingMethods) {
     163        if (!validateShippingMethod(shippingMethod))
     164            return false;
     165    }
     166
     167    return true;
     168}
     169
    149170}
    150171
  • trunk/Source/WebCore/Modules/applepay/PaymentRequestValidator.h

    r202309 r202341  
    4848    bool validateSupportedNetworks(const PaymentRequest::SupportedNetworks&) const;
    4949
     50    bool validateShippingMethods(const Vector<PaymentRequest::ShippingMethod>&) const;
     51    bool validateShippingMethod(const PaymentRequest::ShippingMethod&) const;
     52
    5053    DOMWindow& m_window;
    5154};
Note: See TracChangeset for help on using the changeset viewer.