LibreChat/api/server/controllers/agents
Danny Avila 485eb2dfff 🔒 fix: gate office HTML routing on backend trust flag (textFormat)
Codex P1 review on PR #12934: routing .docx/.csv/.xlsx/.xls/.ods/.pptx
into the office preview buckets assumed `attachment.text` was already
sanitized full-document HTML, but that guarantee only existed for the
new code-output extractor path. Existing stored attachments and other
non-code paths can still carry plain extracted text — `useArtifactProps`
would then inject that as `index.html` inside the Sandpack iframe.

Adds a `textFormat: 'html' | 'text' | null` trust flag persisted on
the file record by the code-output extractor, surfaced over the SSE
attachment payload and the TFile API type. The client's routing in
`detectArtifactTypeFromFile` requires `textFormat === 'html'` before
landing on an office HTML bucket; everything else (legacy attachments,
RAG-extracted plain text from `parseDocument`, explicitly-marked
'text' entries) falls back to the PLAIN_TEXT bucket where the
markdown viewer escapes content rather than executing it.

Tests: new `getExtractedTextFormat` helper has 14 cases covering all
office paths, legacy XLS MIME aliases, parseDocument fallthroughs,
and null-input. Client `artifacts.test.ts` adds three security-gate
tests proving downgrade behavior for missing/null/'text' textFormat,
plus a `fileToArtifact` test that legacy office attachments without
the flag end up in PLAIN_TEXT with their content escaped.
2026-05-04 16:56:09 -04:00
..
__tests__ 🛡️ fix: Strict Opt-In Skills Activation per Agent (#12823) 2026-04-25 04:02:01 -04:00
callbacks.js 🔒 fix: gate office HTML routing on backend trust flag (textFormat) 2026-05-04 16:56:09 -04:00
client.js 🧬 chore: Align LibreChat With Agents LangChain Upgrade (#12922) 2026-05-03 12:46:01 -04:00
client.test.js 🧬 chore: Align LibreChat With Agents LangChain Upgrade (#12922) 2026-05-03 12:46:01 -04:00
errors.js 📦 refactor: Consolidate DB models, encapsulating Mongoose usage in data-schemas (#11830) 2026-03-21 14:28:53 -04:00
filterAuthorizedTools.spec.js 🏗️ refactor: Remove Redundant Caching, Migrate Config Services to TypeScript (#12466) 2026-03-30 16:49:48 -04:00
openai.js 🛡️ fix: Strict Opt-In Skills Activation per Agent (#12823) 2026-04-25 04:02:01 -04:00
recordCollectedUsage.spec.js 🪢 chore: Consolidate Pricing and Tx Imports After tx.js Module Removal (#12086) 2026-03-21 14:28:53 -04:00
request.js 📌 fix: Stabilize Agent Prompt Cache Prefix (#12907) 2026-05-02 09:55:31 +09:00
responses.js 🛡️ fix: Strict Opt-In Skills Activation per Agent (#12823) 2026-04-25 04:02:01 -04:00
v1.js 🪆 feat: Subagent configuration in Agent Builder (#12725) 2026-04-25 04:02:01 -04:00
v1.spec.js 🧹 fix: Clean Up Orphaned Agent File Stubs After Deletion (#12781) 2026-04-22 11:35:48 -07:00