-
-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: extract shared escapeHtml utility from duplicated implementations #3215
Copy link
Copy link
Open
Description
Context
Discovered during code review of PR #3183 (CodeQL fixes for #3164).
Problem
escapeHtml() is defined independently in two places with identical logic:
autobot-frontend/src/utils/cacheManagement.ts(added in PR fix(security): resolve ~14 JavaScript CodeQL alerts (#3164) #3183)autobot-frontend/src/components/analytics/CodeGenerationDashboard.vue(existing)
This violates the CLAUDE.md rule: "Reuse Existing Code — import from autobot_shared/, never duplicate or hardcode."
Additionally, the cacheManagement.ts version is missing the single-quote (' → ') escape that the CodeGenerationDashboard.vue version includes.
Expected behavior
Extract a shared escapeHtml function to autobot-frontend/src/utils/sanitize.ts (which already has DOMPurify-based sanitization) or a new htmlHelpers.ts, and import it in both locations.
Files
autobot-frontend/src/utils/cacheManagement.tsautobot-frontend/src/components/analytics/CodeGenerationDashboard.vueautobot-frontend/src/utils/sanitize.ts(candidate shared location)
Related
Reactions are currently unavailable