diff --git a/app/Http/Requests/Bo/Products/StoreProductRequest.php b/app/Http/Requests/Bo/Products/StoreProductRequest.php
index 896bd189..c97a0b52 100644
--- a/app/Http/Requests/Bo/Products/StoreProductRequest.php
+++ b/app/Http/Requests/Bo/Products/StoreProductRequest.php
@@ -144,7 +144,7 @@ class StoreProductRequest extends FormRequest
{
return [
'name' => ['required', 'string', 'min:3', 'max:255'],
- 'brand' => ['sometimes', 'nullable', 'string', 'min:3', 'max:255'],
+ 'brand' => ['required', 'string', new Enum(ProductBrand::class)],
'short_description' => ['required', 'string', 'min:15', 'max:100'],
'description' => ['required', 'string', 'min:15'],
'price' => ['required', 'min:0', 'numeric'],
@@ -169,7 +169,7 @@ class StoreProductRequest extends FormRequest
'order_unit' => ['required', new Enum(OrderUnit::class)],
'tax_rate' => ['required', new Enum(TaxRate::class)],
- 'picture' => [
+ 'picture' => [
Rule::imageFile()
->extensions(self::ALLOWED_EXTENSIONS)
->rules([
@@ -183,7 +183,9 @@ class StoreProductRequest extends FormRequest
->height(static::PICTURE_HEIGHT)
),
],
- 'picture_large' => [
+ 'picture_alt' => ['nullable', 'string', 'max:255'],
+ 'picture_title' => ['nullable', 'string', 'max:255'],
+ 'picture_large' => [
Rule::imageFile()
->extensions(self::ALLOWED_EXTENSIONS)
->rules([
@@ -197,6 +199,8 @@ class StoreProductRequest extends FormRequest
->height(static::PICTURE_LARGE_HEIGHT)
),
],
+ 'picture_large_alt' => ['nullable', 'string', 'max:255'],
+ 'picture_large_title' => ['nullable', 'string', 'max:255'],
'associated_products' => ['present', 'array'],
'associated_products.*' => ['string', 'exists:products,id'],
diff --git a/resources/ts/fo/services/toast.service.test.ts b/resources/ts/fo/services/toast.service.test.ts
new file mode 100644
index 00000000..3f5bc3dc
--- /dev/null
+++ b/resources/ts/fo/services/toast.service.test.ts
@@ -0,0 +1,36 @@
+// @vitest-environment jsdom
+import {beforeEach, describe, expect, it, vi} from "vitest";
+
+import { ToastService } from "./toast.service";
+
+const { showMock } = vi.hoisted(() => ({showMock: vi.fn(),}));
+
+vi.mock("bootstrap", () => ({
+ Toast: class {
+ public show = showMock;
+ public hide = vi.fn();
+ },
+}));
+
+describe("ToastService", () => {
+ beforeEach(() => {
+ document.body.innerHTML = "";
+ showMock.mockClear();
+ });
+
+ it("renders message as plain text without interpreting injected HTML", () => {
+ // GIVEN
+ const service = new ToastService();
+ const xssPayload = "Erreur";
+
+ // WHEN
+ service.show(xssPayload, "danger");
+
+ // THEN
+ const body = document.querySelector("#fo-toast-container .toast-body");
+ expect(body).not.toBeNull();
+ expect(body?.querySelector("img")).toBeNull();
+ expect(body?.textContent).toBe(xssPayload);
+ expect(showMock).toHaveBeenCalledOnce();
+ });
+});
diff --git a/resources/ts/fo/services/toast.service.ts b/resources/ts/fo/services/toast.service.ts
index 0632a1bb..10579987 100644
--- a/resources/ts/fo/services/toast.service.ts
+++ b/resources/ts/fo/services/toast.service.ts
@@ -76,7 +76,28 @@ export class ToastService {
el.dataset["bsDelay"] = String(opts.delay ?? 4000);
}
- el.innerHTML = `
Rôti <img src=x onerror=alert(1)>
'; + $product->picture_alt = 'alt'; + $product->picture_title = 'title'; + $product->picture_large_alt = 'alt'; + $product->picture_large_title = 'title'; + $product->price = Money::EUR(1500); + $product->invoicing_unit = InvoicingUnit::PCE; + $product->sell_unit = SellUnit::PCE; + $product->tax_rate = TaxRate::TVA_5_5; + $product->stock = 10; + $product->range_id = $range->id; + $product->order = 1; + $product->star = true; + $product->status = true; + $product->save(); + + // WHEN + $response = $this->get('/'); + + // THEN + $response->assertOk(); + $response->assertDontSee('