Text in pro product_id
Posted: Sat Sep 21, 2019 8:20 pm
Hello!
We noticed that OpenCart accepts product_id numbers and text, thereby opening a double of the old page.
For example: product_id = 43AZAZAZAZAZA
https://demo.opencart.com/index.php?rou ... ZAZAZAZAZA
Such a page should give a 404 error!
We fixed this bug like this:
Perhaps there is a more correct solution to the problem?
Thank!
We noticed that OpenCart accepts product_id numbers and text, thereby opening a double of the old page.
For example: product_id = 43AZAZAZAZAZA
https://demo.opencart.com/index.php?rou ... ZAZAZAZAZA
Code: Select all
<link href="https://demo.opencart.com/index.php?route=product/product&product_id=43AZAZAZAZAZA" rel="canonical" />
<input type="hidden" name="redirect" value="https://demo.opencart.com/index.php?route=product/product&[b]product_id=43AZAZAZAZAZA" />
<li><a href="https://demo.opencart.com/index.php?route=product/product&product_id=43AZAZAZAZAZA">MacBook</a></li>
We fixed this bug like this:
Code: Select all
/catalog/controller/product/product.php
if (isset($this->request->get['product_id'])) {
// проверка на такие товары index.php?route=product/product&path=71_77&product_id=53asdasdasd
if(filter_var($this->request->get['product_id'],FILTER_VALIDATE_INT)){
$product_id = (int)$this->request->get['product_id'];
}
else
{
$product_id = 0;
}
} else {
$product_id = 0;
}
Thank!