If you have ever helped a small business or bookkeeper do catch-up bookkeeping for a corporate credit card with multiple employee cards, you have probably seen two painful things happen:

Debit and Credit columns, or I wanted to see how far you can push a 100% client-side, zero-upload bookkeeping utility using plain static HTML, CSS, and vanilla JavaScript—with zero backend upload endpoints and deterministic verification instead of probabilistic AI guesses.

The result is StatementUnpack—and along the way, I ran into several surprisingly subtle engineering and security details worth sharing.

Saying "we don't upload your files" on a landing page is easy. Making it verifiable in DevTools is much better.

StatementUnpack ships as pure static files with a strict Content-Security-Policy header on every route:

Content-Security-Policy:
  default-src 'none';
  script-src 'self';
  style-src 'self';
  worker-src 'self';
  connect-src 'self';
  img-src 'self';
  base-uri 'none';
  form-action 'none';
  frame-ancestors 'none'

What this enforces in practice:

pdfjs-dist@5.6.205) and its worker are vendored locally on the same origin and verified against pinned SHA-256 hashes at build time.form-action 'none' and connect-src 'self' block accidental data exfiltration to external domains.File.arrayBuffer() / File.text(), processed in browser memory, and exported locally as Blob downloads. You can open Chrome DevTools → (Full disclosure: the site does load Vercel's cookie-free, same-origin Web Analytics script /_vercel/insights/script.js for basic anonymous pageview counts—never file names, file contents, or transaction data.)

BigInt Cent Math Matters for Financial Parsing A surprising number of quick-and-dirty statement parsers parse currency strings with parseFloat(). That works right up until a 40-transaction statement fails an opening/closing balance check by $0.0000000000000284.

In the PDF parser (parser.js), every dollar amount is normalized directly into integer cents as a BigInt before any arithmetic runs:

const cents = value => BigInt(value.replace(/[,.]/g, ''));

const format = cents => {
  const parts = (cents < 0n ? -cents : cents).toString().padStart(3, '0');
  return (cents < 0n ? '-' : '') + parts.slice(0, -2) + '.' + parts.slice(-2);
};

Combined with deterministic column boundaries and per-account reconciliation (previousBalance + netTransactions === newBalance), the PDF splitter refuses to silently drop a row or guess a missing figure. If anything doesn't reconcile—or if a file is an unsupported layout or scanned image—it halts export and produces a structured review-only.json report instead.

Here is a security edge case that bites almost every CSV exporter: CSV / Spreadsheet Formula Injection.

If an untrusted merchant description or cardholder label starts with =, +, -, @ (or their full-width Unicode equivalents =, +, -, @, even after leading whitespace or a UTF-8 BOM), opening the exported CSV in Excel or Google Sheets can trigger formula execution.

At the same time, QuickBooks credit card CSVs require legitimate negative numbers like -42.50 in the Amount column!

So instead of blindly prefixing every cell with an apostrophe (which corrupts numeric Amount columns in QuickBooks), StatementUnpack separates untrusted text cells from validated numeric fields:

const FORMULA_PREFIX = /^[=+\-@=+-@]/u;
const CONTROL_CHARS = /[\x00-\x1f\x7f-\x9f]/u;

export function isSafeCell(value) {
  const str = String(value ?? '');
  return (
    !CONTROL_CHARS.test(str) &&
    !FORMULA_PREFIX.test(str.replace(/^[\s\uFEFF]+/u, ''))
  );
}

Amount values are formatted strictly as numeric decimals (-42.50 or 120.00). Date, Description, cardholder name) and filename is checked against FORMULA_PREFIX and CONTROL_CHARS. innerHTML) and Parsing untrusted PDFs inside a user's browser carries its own DoS/security risks: PDF JavaScript actions (OpenAction), XFA forms, huge page counts, or console-log leakage of raw PDF tokens.

To keep browser parsing predictable:

10 MiB, max 20 pages, a 30s soft timeout, max 35,000 extracted text items, and max 2,097,152 UTF-16 code units. I want to be completely transparent about what is validated today versus what isn't:

Card Member / Cardholder / Card No. columns and splits combined corporate card CSVs into one 3-column CSV per card.$/commas/parentheses/ CR/ DR, and flips reversed QuickBooks Online signs in one click. If you want to poke at the CSP headers, inspect the Network tab, or test the CSV splitter with a dummy/redacted business card export:

👉 Try the CSV Splitter (any bank): https://statementunpack.com/tools/csv-splitter/

👉 Try the PDF Splitter Demo: https://statementunpack.com/

Before I build PDF parsers for additional banks, I'm trying to learn from real-world workflows:

Drop a comment below—blunt technical or UX feedback is super welcome!

原文来源:dev.to