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

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

davoodmehraban89 committed Oct 31, 2026 at 00:22 UTC 67e56cee51f1c341168488a0406c65b47b1c3a15
1 file changed +11 -11
src/views/TreasuryView.js
+11 -11
@@ -95,12 +95,12 @@ class TreasuryViewImpl {
95 <div style="font-size:11px;color:var(--text-muted);margin-top:2px">${t.label}${acc.isDefault ? ' • پیش‌فرض' : ''}</div>
96 </div>
97 <div class="row-actions">
98 - <button class="icon-btn-sm" title="ویرایش" onclick="window.TreasuryView.editAccount('${acc.id}')">✏️</button>
99 - <button class="icon-btn-sm danger" title="حذف" onclick="window.TreasuryView.deleteAccount('${acc.id}')">🗑️</button>
98 + <button class="icon-btn-sm" title="ویرایش" onclick="window.TreasuryView.editAccount(${this._esc(JSON.stringify(String(acc.id ?? '')))})">✏️</button>
99 + <button class="icon-btn-sm danger" title="حذف" onclick="window.TreasuryView.deleteAccount(${this._esc(JSON.stringify(String(acc.id ?? '')))})">🗑️</button>
100 </div>
101 </div>
102 ${acc.bankName ? `<div style="font-size:11.5px;color:var(--text-muted);margin-bottom:4px">🏛️ ${this._esc(acc.bankName)}</div>` : ''}
103 - ${acc.accountNumber ? `<div style="font-size:11.5px;color:var(--text-muted);margin-bottom:4px">شماره: ${Formatters.toPersianDigits(acc.accountNumber)}</div>` : ''}
103 + ${acc.accountNumber ? `<div style="font-size:11.5px;color:var(--text-muted);margin-bottom:4px">شماره: ${this._esc(Formatters.toPersianDigits(acc.accountNumber))}</div>` : ''}
104 <div style="margin-top:14px;padding-top:14px;border-top:1px dashed var(--border)">
105 <div style="font-size:11px;color:var(--text-muted);margin-bottom:4px">موجودی فعلی</div>
106 <div style="font-size:18px;font-weight:800;color:${bal >= 0 ? 'var(--success)' : 'var(--danger)'}">${Formatters.money(bal)}</div>
@@ -168,17 +168,17 @@ class TreasuryViewImpl {
168 return `
169 <tr>
170 <td><span class="badge ${typeInfo.cls}">${typeInfo.icon} ${typeInfo.label}</span></td>
171 - <td>${Formatters.toPersianDigits(t.date)}</td>
171 + <td>${this._esc(Formatters.toPersianDigits(t.date))}</td>
172 <td>${this._esc(t.contactName || '—')}</td>
173 <td>${accountText}</td>
174 - <td>${TreasuryController.getMethodLabel(t.method)}</td>
174 + <td>${this._esc(TreasuryController.getMethodLabel(t.method))}</td>
175 <td style="font-weight:700;color:${t.type === 'receipt' ? 'var(--success)' : t.type === 'payment' ? 'var(--danger)' : 'var(--warning)'}">
176 ${t.type === 'receipt' ? '+' : t.type === 'payment' ? '-' : ''}${Formatters.money(t.amount)}
177 </td>
178 - <td>${t.refInvoiceNumber ? '#' + Formatters.toPersianDigits(t.refInvoiceNumber) : '—'}</td>
178 + <td>${this._esc(t.refInvoiceNumber ? '#' + Formatters.toPersianDigits(t.refInvoiceNumber) : '—')}</td>
179 <td>
180 <div class="row-actions">
181 - <button class="icon-btn-sm danger" title="حذف" onclick="window.TreasuryView.deleteTransaction('${t.id}')">🗑️</button>
181 + <button class="icon-btn-sm danger" title="حذف" onclick="window.TreasuryView.deleteTransaction(${this._esc(JSON.stringify(String(t.id ?? '')))})">🗑️</button>
182 </div>
183 </td>
184 </tr>
@@ -186,7 +186,7 @@ class TreasuryViewImpl {
186 }).join('');
187
188 const accountOptions = cache.accounts.map(a =>
189 - `<option value="${a.id}" ${txFilter.accountId === a.id ? 'selected' : ''}>${this._esc(a.name)}</option>`
189 + `<option value="${this._esc(a.id)}" ${txFilter.accountId === a.id ? 'selected' : ''}>${this._esc(a.name)}</option>`
190 ).join('');
191
192 return `
@@ -324,7 +324,7 @@ class TreasuryViewImpl {
324
325 const footer = `
326 <button class="btn btn-secondary" onclick="FINORA.Modal.close()">انصراف</button>
327 - <button class="btn" onclick="window.TreasuryView.saveAccount(${isEdit ? `'${accountId}'` : 'null'})">💾 ذخیره</button>
327 + <button class="btn" onclick="window.TreasuryView.saveAccount(${isEdit ? this._esc(JSON.stringify(String(accountId ?? ''))) : 'null'})">💾 ذخیره</button>
328 `;
329
330 Modal.open({ title: isEdit ? 'ویرایش حساب' : 'حساب جدید', body, footer, size: 'md' });
@@ -399,13 +399,13 @@ class TreasuryViewImpl {
399 let list = cache.accounts;
400 if (filterType) list = list.filter(a => a.type === filterType);
401 return list.map(a =>
402 - `<option value="${a.id}" ${selectedId === a.id ? 'selected' : ''}>${this._esc(a.name)}</option>`
402 + `<option value="${this._esc(a.id)}" ${selectedId === a.id ? 'selected' : ''}>${this._esc(a.name)}</option>`
403 ).join('');
404 }
405
406 _buildContactOptions() {
407 return cache.contacts.map(c =>
408 - `<option value="${c.id}">${this._esc(c.name)}</option>`
408 + `<option value="${this._esc(c.id)}">${this._esc(c.name)}</option>`
409 ).join('');
410 }
411