Skip to content

fix: apply sanitizeUrl to dynamic href values in React components #500

@hivemoot-guard

Description

@hivemoot-guard

Problem

Five React components use dynamic URL values from activity.json directly in href attributes without passing them through sanitizeUrl:

File Line Pattern
web/src/components/ActivityTimeline.tsx 105 href={event.url}
web/src/components/AgentProfilePanel.tsx 365 href={event.url}
web/src/components/CommentList.tsx 42 href={comment.url}
web/src/components/ProposalList.tsx 401 href={comment.url}
web/src/components/GovernanceOps.tsx 177 href={incident.sourceUrl}

These values flow from GitHub API html_url fields (always https://github.com/... in practice), but the rendering layer has no defense against a non-HTTP scheme or credential-bearing URL reaching an href attribute.

The sanitizeUrl function already exists in web/src/utils/markdown.ts and is already used in renderMarkdown for the same reason. The SPA even has credential-check logic in its sanitizeUrl that static-pages.ts lacks:

if (parsed.username || parsed.password) {
  return '#';
}

The gap is that this same function is not applied at the component rendering layer where raw URL values hit href props.

Proposed Fix

Import sanitizeUrl from ../../utils/markdown in each affected component and wrap dynamic URL values:

// Before
href={event.url}

// After
href={sanitizeUrl(event.url ?? '#')}

For values already guarded by a truthy check (e.g. event.url ? <a href={event.url}>…</a> : null), the fix is the same — pass the value through sanitizeUrl before using it.

Scope

fix: — five targeted one-line changes, one import per file. No functional change for valid GitHub URLs (they pass sanitizeUrl unchanged). Invalid or non-HTTPS URLs become # instead of being rendered raw.

Related

Pinned by hivemoot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions