fix(products): encode html for title on products page
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Handlers;
|
||||
|
||||
use App\Support\Utils;
|
||||
use Openguru\OpenCartFramework\Config\Settings;
|
||||
use Openguru\OpenCartFramework\Http\JsonResponse;
|
||||
use Openguru\OpenCartFramework\Http\Request;
|
||||
@@ -79,7 +80,7 @@ class CategoriesHandler
|
||||
return [
|
||||
'id' => (int)$category['id'],
|
||||
'image' => $category['image'] ?? '',
|
||||
'name' => html_entity_decode($category['name'], ENT_QUOTES | ENT_HTML5, 'UTF-8'),
|
||||
'name' => Utils::htmlEntityEncode($category['name']),
|
||||
'description' => $category['description'],
|
||||
'children' => $category['children'],
|
||||
];
|
||||
@@ -102,7 +103,7 @@ class CategoriesHandler
|
||||
$branch[] = [
|
||||
'id' => (int)$category['id'],
|
||||
'image' => $image,
|
||||
'name' => html_entity_decode($category['name'], ENT_QUOTES | ENT_HTML5, 'UTF-8'),
|
||||
'name' => Utils::htmlEntityEncode($category['name']),
|
||||
'description' => $category['description'],
|
||||
'children' => $category['children'] ?? [],
|
||||
];
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Support\Utils;
|
||||
use Cart\Currency;
|
||||
use Cart\Tax;
|
||||
use Exception;
|
||||
@@ -147,7 +148,7 @@ class ProductsService
|
||||
|
||||
$allImages[] = [
|
||||
'url' => $image,
|
||||
'alt' => html_entity_decode($product['product_name'], ENT_QUOTES | ENT_HTML5, 'UTF-8'),
|
||||
'alt' => Utils::htmlEntityEncode($product['product_name']),
|
||||
];
|
||||
|
||||
$price = $this->currency->format(
|
||||
@@ -178,7 +179,7 @@ class ProductsService
|
||||
return [
|
||||
'id' => (int) $product['product_id'],
|
||||
'product_quantity' => (int) $product['product_quantity'],
|
||||
'name' => html_entity_decode($product['product_name'], ENT_QUOTES | ENT_HTML5, 'UTF-8'),
|
||||
'name' => Utils::htmlEntityEncode($product['product_name']),
|
||||
'price' => $price,
|
||||
'special' => $special,
|
||||
'images' => $allImages,
|
||||
@@ -224,16 +225,14 @@ class ProductsService
|
||||
$data['tab_review'] = sprintf($this->oc->language->get('tab_review'), $product_info['reviews']);
|
||||
|
||||
$data['product_id'] = $productId;
|
||||
$data['name'] = $product_info['name'];
|
||||
$data['name'] = Utils::htmlEntityEncode($product_info['name']);
|
||||
$data['manufacturer'] = $product_info['manufacturer'];
|
||||
$data['model'] = $product_info['model'];
|
||||
$data['reward'] = $product_info['reward'];
|
||||
$data['points'] = (int) $product_info['points'];
|
||||
$data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
|
||||
$data['share'] = html_entity_decode(
|
||||
$this->oc->url->link('product/product', 'product_id=' . $productId),
|
||||
ENT_QUOTES | ENT_HTML5,
|
||||
'UTF-8'
|
||||
$data['description'] = Utils::htmlEntityEncode($product_info['description']);
|
||||
$data['share'] = Utils::htmlEntityEncode(
|
||||
$this->oc->url->link('product/product', 'product_id=' . $productId)
|
||||
);
|
||||
|
||||
if ($product_info['quantity'] <= 0) {
|
||||
@@ -272,7 +271,7 @@ class ProductsService
|
||||
),
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'alt' => html_entity_decode($product_info['name'], ENT_QUOTES | ENT_HTML5, 'UTF-8'),
|
||||
'alt' => Utils::htmlEntityEncode($product_info['name']),
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
$this->logger->logException($e);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
final class Utils
|
||||
{
|
||||
public static function htmlEntityEncode(string $string): string
|
||||
{
|
||||
return html_entity_decode($string, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user