Skip to content

Commit

Permalink
[16.0][FIX] website_sale_cart_expire: Protect _setExpirationDate assi…
Browse files Browse the repository at this point in the history
…gnment error

Added format check before setting the datetime in str_to_datetime in order to avoid error message in website.

It checks "/shop/cart/get_expire_date" url to retrieve the information, but when it's installed some module that restricts the access to some url (like website_require_login) it retrieves HTML from the redirection.

Function evaluates "expireDate" as string and tries to convert it to datetime, but it's not a date so raises throws error.

Now checks if the string has a valid format date before try to convert it otherwise sets "expireDate" to undefined.
  • Loading branch information
Pablo De Andrés committed Sep 7, 2023
1 parent 1a8d70e commit 8bbb2ca
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ odoo.define("website_sale_cart_expire", (require) => {
* @param {String|Date} expireDate
*/
_setExpirationDate: function (expireDate) {
if (typeof expireDate === "string") {
if (typeof expireDate === "string" && !isNaN(Date.parse(expireDate))) {
expireDate = time.str_to_datetime(expireDate);
}else{
expireDate = undefined;
}
this.expireDate = expireDate ? moment(expireDate) : false;
},
Expand Down

0 comments on commit 8bbb2ca

Please sign in to comment.