Skip to content

Commit

Permalink
Validate item instance id
Browse files Browse the repository at this point in the history
  • Loading branch information
onbirdev committed Dec 2, 2024
1 parent 9dc21c0 commit 12a4674
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions classes/local/object/cookie_cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ class cookie_cart extends base_cart {
public function init() {
if (isset($_COOKIE[$this->cookiename])) {
$this->_cookie_items = json_decode(stripslashes($_COOKIE[$this->cookiename]), true);

// Validate each item in the decoded data to ensure it is an integer.
// Remove any invalid (non-integer) items from the list.
foreach ($this->_cookie_items as $key => $instanceid) {
if (!is_int($instanceid)) {
unset($this->_cookie_items[$key]);
}
}
}
}

Expand Down

0 comments on commit 12a4674

Please sign in to comment.