Repository navigation
Open
Labels
Description
Goal
Strengthen Give's transparency moat by letting any donor, journalist, or auditor download a formula-safe CSV or print/save a clean PDF directly from any public campaign statement page.
Scope (App-only — DOS/Give)
- Shared Formula-Safe CSV Builder (
apps/web/src/lib/csv.ts+ tests):- Pure RFC-4180 CSV serializer with optional UTF-8 BOM (
\uFEFF) for Vietnamese Excel compatibility. - Strict CSV Formula Injection neutralization: prefix
'on any cell whose trimmed/untrimmed value starts with=,+,-,@,\t, or\r, plus proper double-quote escaping. - Safe filename slug helper.
- Pure RFC-4180 CSV serializer with optional UTF-8 BOM (
- Public Statement CSV Export Route (
apps/web/src/app/campaigns/[slug]/statement/export/route.ts+ tests):- Public
GEThandler supporting?filter=all|in|out|unexplainedviaparseStatementParams. - Validates
slug(SLUG_PATTERN,<= 80), reads strictly via anonymousdbAs(), and requiresisPublicStatus(campaign.status)(404for drafts, pre-launch teasers, suspended, or cancelled campaigns). - Paginates
give.public_statementup to a hard cap of5,000rows (settingX-Statement-Truncated: truewhentotal > 5000). - Exports strictly public statement fields (
Thời gian,Loại,Số tiền (VND),Nhóm,Đối tác (công khai),Trạng thái giải trình,Nội dung giải trình) — zero private donor PII, refund evidence, or receiving bank account numbers. - Headers:
Content-Type: text/csv; charset=utf-8,Content-Disposition: attachment; filename="sao-ke-${slug}.csv",Cache-Control: public, s-maxage=60, stale-while-revalidate=300,X-Content-Type-Options: nosniff,X-Robots-Tag: noindex, nofollow.
- Public
- Statement Header Controls & Print/PDF Styling:
- Add
PrintStatementButton.tsx(window.print()) and"Tải CSV sao kê"link (preserving activefilter) onapps/web/src/app/campaigns/[slug]/statement/page.tsx. - Add clean
@media printstyles inapps/web/src/app/globals.css: hide header/footer/nav/.print:hidden, render clean black-on-white typography, print masthead with campaign title/link/date, andbreak-inside: avoidon summary & statement rows.
- Add
Acceptance Criteria
pnpm --filter @give/web test,typecheck,lint, andbuildpass cleanly.- Zero leakage of private/suspended/pre-launch campaigns or non-public donor/refund info; CSV formula injection tested and neutralized.
- Two independent reviews (worker + PO flagship review) pass with zero unresolved P0/P1/P2 findings.
Activity
fix(statement): exclude CSV export from session proxy & harden Unicod…
feat(statement): formula-safe CSV export & print-friendly PDF view (R…
JOY commentedon Nov 23, 2026
Merged to dev (PR #340) — live on beta.give.vn, awaiting Production promotion.
docs(changelog): sync CHANGELOG.md for Give v3 (#334-#338) (#345)