فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
fix(security): safely encode accounting journal, period and stocktake IDs
davoodmehraban89 committed
Oct 31, 2026 at 00:38 UTC
0e49e58e248881be5558d92fb224f1dd22227536
1 file changed
+9
-7
src/views/AccountingView.js
+9
-7
@@ -14,6 +14,8 @@ import { ACCOUNT_LEVELS, ACCOUNT_TYPES } from '../core/AccountingCore.mjs';
14
const levelNames = { group: 'گروه', general: 'کل', subsidiary: 'معین', detail: 'تفصیلی' };
15
const typeNames = { asset: 'دارایی', liability: 'بدهی', equity: 'حقوق مالکانه', revenue: 'درآمد', expense: 'هزینه' };
16
const html = value => String(value ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
17
+// Encode both JavaScript argument quotes and the enclosing HTML attribute.
18
+const actionArg = value => html(JSON.stringify(String(value ?? '')));
19
const digits = input => String(input ?? '').replace(/[۰-۹]/g, c => String(c.charCodeAt(0) - 1776)).replace(/[٠-٩]/g, c => String(c.charCodeAt(0) - 1632));
20
const rial = input => {
21
const raw = digits(input).replace(/[,_،\s]/g, '');
@@ -203,7 +205,7 @@ class AccountingViewImpl {
205
<td><strong>${html(p.name)}</strong></td>
206
<td>${html(p.startDate)}</td><td>${html(p.endDate)}</td>
207
<td><span class="badge ${p.closed ? 'badge-muted' : 'badge-success'}">${p.closed ? 'بسته' : 'باز'}</span></td>
206
- <td>${p.closed ? '—' : `<button class="btn btn-secondary" onclick="window.AccountingView.closePeriod('${html(p.id)}')">بستن دوره</button>`}</td></tr>`).join('');
208
+ <td>${p.closed ? '—' : `<button class="btn btn-secondary" onclick="window.AccountingView.closePeriod(${actionArg(p.id)})">بستن دوره</button>`}</td></tr>`).join('');
209
return `<div class="card">
210
<div class="toolbar"><strong>دورههای مالی</strong>
211
<button class="btn" onclick="window.AccountingView.openPeriodModal()">افزودن دوره مالی</button></div>
@@ -230,12 +232,12 @@ class AccountingViewImpl {
232
<td>${Formatters.number(j.debit || 0)}</td><td>${Formatters.number(j.credit || 0)}</td>
233
<td><span class="badge ${j.status === 'posted' ? 'badge-success' : 'badge-warning'}">${j.status === 'posted' ? 'قطعی' : 'پیشنویس'}</span>${j.reversedById ? ' / برگشتخورده' : ''}</td>
234
<td style="white-space:nowrap">
233
- <button class="btn btn-secondary" onclick="window.AccountingView.showJournal('${html(j.id)}')">مشاهده</button>
234
- ${j.status === 'draft' ? `<button class="btn btn-secondary" onclick="window.AccountingView.openJournalModal('${html(j.id)}')">ویرایش</button>
235
- <button class="btn" onclick="window.AccountingView.postDraft('${html(j.id)}')">قطعی</button>
236
- <button class="btn btn-secondary" onclick="window.AccountingView.deleteDraft('${html(j.id)}')">حذف پیشنویس</button>` : ''}
235
+ <button class="btn btn-secondary" onclick="window.AccountingView.showJournal(${actionArg(j.id)})">مشاهده</button>
236
+ ${j.status === 'draft' ? `<button class="btn btn-secondary" onclick="window.AccountingView.openJournalModal(${actionArg(j.id)})">ویرایش</button>
237
+ <button class="btn" onclick="window.AccountingView.postDraft(${actionArg(j.id)})">قطعی</button>
238
+ <button class="btn btn-secondary" onclick="window.AccountingView.deleteDraft(${actionArg(j.id)})">حذف پیشنویس</button>` : ''}
239
${j.status === 'posted' && !j.reversedById && !j.reversalOfId
238
- ? `<button class="btn btn-secondary" onclick="window.AccountingView.openReversal('${html(j.id)}')">برگشت</button>` : ''}
240
+ ? `<button class="btn btn-secondary" onclick="window.AccountingView.openReversal(${actionArg(j.id)})">برگشت</button>` : ''}
241
</td></tr>`).join('');
242
return `<div class="card">
243
<div class="toolbar"><strong>اسناد حسابداری مستقل</strong>
@@ -572,7 +574,7 @@ class AccountingViewImpl {
574
<td>${Formatters.number(b.quantityUnits/1000)}</td><td>${Formatters.number(b.value)} ریال</td></tr>`).join('');
575
const takeRows=stocktakes.map(s=>`<tr><td>${html(warehouseNames[s.warehouseId]||s.warehouseId)}</td>
576
<td>${html(s.date)}</td><td>${s.status==='draft'?'در انتظار شمارش':'قطعی'}</td>
575
- <td><button class="btn btn-secondary" onclick="window.AccountingView.openStocktake('${html(s.id)}')">مشاهده و شمارش</button></td></tr>`).join('');
577
+ <td><button class="btn btn-secondary" onclick="window.AccountingView.openStocktake(${actionArg(s.id)})">مشاهده و شمارش</button></td></tr>`).join('');
578
return `<div class="card"><div class="toolbar"><strong>حسابداری یکپارچه فعال است</strong>
579
<button class="btn" onclick="window.AccountingView.openWarehouse()">انبار جدید</button>
580
<button class="btn btn-secondary" onclick="window.AccountingView.openTransfer()">انتقال کالا</button>