Skip to content

refactor: extract shared escapeHtml utility from duplicated implementations #3215

@mrveiss

Description

@mrveiss

Context

Discovered during code review of PR #3183 (CodeQL fixes for #3164).

Problem

escapeHtml() is defined independently in two places with identical logic:

  1. autobot-frontend/src/utils/cacheManagement.ts (added in PR fix(security): resolve ~14 JavaScript CodeQL alerts (#3164) #3183)
  2. 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.ts
  • autobot-frontend/src/components/analytics/CodeGenerationDashboard.vue
  • autobot-frontend/src/utils/sanitize.ts (candidate shared location)

Related

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions