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

test(security): assert accounting and ledger output encoding contracts

davoodmehraban89 committed Oct 31, 2026 at 00:38 UTC 7716f899e0d6a2f77dca621d7c2019f9c676c3de
1 file changed +15
tests/ui-control-structure.test.mjs
+15
@@ -198,6 +198,21 @@ test('A02: Excel imports reject destructive replacement before touching master d
198 'untrusted filenames must never be embedded as executable inline HTML');
199 });
200
201 +test('A03: company switch, posted journals and printable ledger encode untrusted IDs', () => {
202 + const settings=fs.readFileSync(path.join(root,'src','views','SettingsView.js'),'utf8');
203 + const accounting=fs.readFileSync(path.join(root,'src','views','AccountingView.js'),'utf8');
204 + const ledger=fs.readFileSync(path.join(root,'src','views','ContactLedgerModal.js'),'utf8');
205 + assert.ok(settings.includes('this._esc(JSON.stringify(String(c.id ??')));
206 + assert.ok(accounting.includes('const actionArg = value => html(JSON.stringify(String(value ??')));
207 + assert.ok(!accounting.includes("'${html(j.id)}'"));
208 + assert.ok(!accounting.includes("'${html(p.id)}'"));
209 + assert.ok(!accounting.includes("'${html(s.id)}'"));
210 + assert.ok(ledger.includes('this._esc(JSON.stringify(String(contactId ??')));
211 + assert.ok(ledger.includes('<title>صورت‌حساب ${this._esc(contact.name)}</title>'));
212 + assert.doesNotMatch(ledger,/cdn\.jsdelivr\.net/);
213 + assert.ok(ledger.split('this._esc(Formatters.toPersianDigits(r.date').length>=3);
214 +});
215 +
216 test('Q01: Escape is handled once for nested financial dialogs and shortcut target is topmost', () => {
217 const shortcuts = fs.readFileSync(path.join(root,'src','core','KeyboardShortcuts.js'),'utf8');
218 const modal = fs.readFileSync(path.join(root,'src','core','Modal.js'),'utf8');