فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

fix(security): encode untrusted financial UI content (ProductsView.js)

davoodmehraban89 committed Oct 31, 2026 at 00:22 UTC a565adea0006bf3b8059f8115b80f0de82c2cf53
1 file changed +11 -11
src/views/ProductsView.js
+11 -11
@@ -167,9 +167,9 @@ class ProductsViewImpl {
167 <td>${stockHtml}</td>
168 <td>
169 <div class="row-actions">
170 - ${!isService ? `<button class="icon-btn-sm" title="کاردکس انبار" onclick="window.ProductsView.openKardex('${p.id}')">📊</button>` : ''}
171 - <button class="icon-btn-sm" title="ویرایش" onclick="window.ProductsView.editProduct('${p.id}')">✏️</button>
172 - <button class="icon-btn-sm danger" title="حذف" onclick="window.ProductsView.deleteProduct('${p.id}')">🗑️</button>
170 + ${!isService ? `<button class="icon-btn-sm" title="کاردکس انبار" onclick="window.ProductsView.openKardex(${this._esc(JSON.stringify(String(p.id ?? '')))})">📊</button>` : ''}
171 + <button class="icon-btn-sm" title="ویرایش" onclick="window.ProductsView.editProduct(${this._esc(JSON.stringify(String(p.id ?? '')))})">✏️</button>
172 + <button class="icon-btn-sm danger" title="حذف" onclick="window.ProductsView.deleteProduct(${this._esc(JSON.stringify(String(p.id ?? '')))})">🗑️</button>
173 </div>
174 </td>
175 </tr>
@@ -280,7 +280,7 @@ class ProductsViewImpl {
280 <td>${this._esc(u.symbol || '—')}</td>
281 <td>
282 <div class="row-actions">
283 - <button class="icon-btn-sm danger" title="حذف" onclick="window.ProductsView.deleteUnit('${u.id}')">🗑️</button>
283 + <button class="icon-btn-sm danger" title="حذف" onclick="window.ProductsView.deleteUnit(${this._esc(JSON.stringify(String(u.id ?? '')))})">🗑️</button>
284 </div>
285 </td>
286 </tr>
@@ -315,7 +315,7 @@ class ProductsViewImpl {
315 <td>${parent ? this._esc(parent.name) : '<span class="badge badge-muted">بدون والد</span>'}</td>
316 <td>
317 <div class="row-actions">
318 - <button class="icon-btn-sm danger" title="حذف" onclick="window.ProductsView.deleteCategory('${c.id}')">🗑️</button>
318 + <button class="icon-btn-sm danger" title="حذف" onclick="window.ProductsView.deleteCategory(${this._esc(JSON.stringify(String(c.id ?? '')))})">🗑️</button>
319 </div>
320 </td>
321 </tr>
@@ -348,11 +348,11 @@ class ProductsViewImpl {
348 };
349
350 const unitOptions = cache.units.map(u =>
351 - `<option value="${u.id}" ${data.unitId === u.id ? 'selected' : ''}>${this._esc(u.name)}</option>`
351 + `<option value="${this._esc(u.id)}" ${data.unitId === u.id ? 'selected' : ''}>${this._esc(u.name)}</option>`
352 ).join('');
353
354 const catOptions = cache.categories.map(c =>
355 - `<option value="${c.id}" ${data.categoryId === c.id ? 'selected' : ''}>${this._esc(c.name)}</option>`
355 + `<option value="${this._esc(c.id)}" ${data.categoryId === c.id ? 'selected' : ''}>${this._esc(c.name)}</option>`
356 ).join('');
357
358 const body = `
@@ -422,7 +422,7 @@ class ProductsViewImpl {
422
423 const footer = `
424 <button class="btn btn-secondary" onclick="FINORA.Modal.close()">انصراف</button>
425 - <button class="btn" onclick="window.ProductsView.saveProduct(${isEdit ? `'${productId}'` : 'null'})">💾 ذخیره</button>
425 + <button class="btn" onclick="window.ProductsView.saveProduct(${isEdit ? this._esc(JSON.stringify(String(productId ?? ''))) : 'null'})">💾 ذخیره</button>
426 `;
427
428 Modal.open({
@@ -542,7 +542,7 @@ class ProductsViewImpl {
542 const unitSelect = document.getElementById('pUnit');
543 if (unitSelect) {
544 unitSelect.innerHTML = cache.units.map(u =>
545 - `<option value="${u.id}">${this._esc(u.name)}</option>`
545 + `<option value="${this._esc(u.id)}">${this._esc(u.name)}</option>`
546 ).join('');
547 unitSelect.value = newUnit.id;
548 }
@@ -575,7 +575,7 @@ class ProductsViewImpl {
575 // ============================================================
576 openCategoryModal(fromProductForm = false) {
577 const parentOptions = cache.categories.map(c =>
578 - `<option value="${c.id}">${this._esc(c.name)}</option>`
578 + `<option value="${this._esc(c.id)}">${this._esc(c.name)}</option>`
579 ).join('');
580 const body = `
581 <div class="form-group">
@@ -613,7 +613,7 @@ class ProductsViewImpl {
613 const catSelect = document.getElementById('pCategory');
614 if (catSelect) {
615 catSelect.innerHTML = cache.categories.map(c =>
616 - `<option value="${c.id}">${this._esc(c.name)}</option>`
616 + `<option value="${this._esc(c.id)}">${this._esc(c.name)}</option>`
617 ).join('');
618 catSelect.value = newCategory.id;
619 }