fix: confirm grocycode is of PRODUCT type in GetProductIdFromBarcode (#1581)

* fix: confirm grocycode is of PRODUCT type in GetProductIdFromBarcode

* Fixed formatting

* Don't output the given input (for security reasons)

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
David Mott
2021-08-15 18:45:05 +10:00
committed by GitHub
parent d23f730a0b
commit 95cb9ffb90

View File

@@ -697,6 +697,10 @@ class StockService extends BaseService
if (Grocycode::Validate($barcode))
{
$gc = new Grocycode($barcode);
if ($gc->GetType() != Grocycode::PRODUCT)
{
throw new \Exception('Invalid grocycode');
}
return intval($gc->GetId());
}