Skip to content

fix(ui): escape Markdown special characters in tooltip user values#406

Merged
nullvariant merged 1 commit into
mainfrom
fix/tooltip-markdown-escape
Mar 30, 2026
Merged

fix(ui): escape Markdown special characters in tooltip user values#406
nullvariant merged 1 commit into
mainfrom
fix/tooltip-markdown-escape

Conversation

@nullvariant
Copy link
Copy Markdown
Owner

Summary

  • Add escapeMarkdownInline() pure function in markdownEscape.ts to escape Markdown special characters (\, *, _, `, [, ], <, >, |) and sanitize newlines (\n → space, \r → removed)
  • Apply to all user-supplied values in buildTooltip() (identity name, description, email, SSH host, SSH key, GPG key) and buildMismatchTooltip() (expected/actual mismatch values)
  • Add 15 unit tests covering each character class, edge cases (empty string, combined chars, backslash+pipe), and newline handling
  • Add 1 E2E test verifying pipe escape in mismatch tooltip table

Test plan

  • npx tsc --noEmit passes
  • ESLint passes (0 errors)
  • Unit tests pass (npm run test)
  • Coverage maintained at 100% (markdownEscape.ts: 100% all metrics)
  • Mechanical validation script passes
  • E2E tests pass in CI

🤖 Generated with Claude Code

Prevents display corruption when git config values contain pipe
characters, Markdown formatting syntax, HTML tags, or newlines.
- Add escapeMarkdownInline() in markdownEscape.ts (pure function,
  no VS Code dependency) covering: \ * _ ` [ ] < > |

- Apply to all user-supplied values in buildTooltip() and
  buildMismatchTooltip()
- Add 15 unit tests + 1 E2E test for pipe escape in mismatch table

🖥️ IDE: [Cursor](https://cursor.sh)
🔌 Extension: [Claude Code](https://claude.ai/download)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Model-Raw: claude-opus-4-6
@nullvariant-mimi
Copy link
Copy Markdown
Contributor

🐰 Mimi's Validation Report ✅

All checks are looking good! Great job! 🎉

⏳ Some checks are still running. I will keep watching!


バリデーターを通してくださいね

This report was carefully prepared by nullvariant-mimi[bot]

@github-actions
Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA 7d9c6b6.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@nullvariant-slow
Copy link
Copy Markdown
Contributor

🦥 Slow's Code Review 😩

...yawn... Do I really have to review this?

⚠️ TOO LONG... I can barely keep my eyes open reading these:

File Lines

| extensions/git-id-switcher/src/test/e2e/statusBar.test.ts | 581 |

Split it up... reading long files is exhausting.


働きたくないでござる

This review was reluctantly filed by nullvariant-slow[bot]

@nullvariant-ciel
Copy link
Copy Markdown
Contributor

nullvariant-ciel Bot commented Mar 30, 2026

🕊️ Ciel's Mediation 🌤️

*~~ floating down from the clouds ~~ The zoo seems a bit noisy today...*

2 zoo members have reviewed this PR.

Zoo Member Status
🦥 Slow Commented
🐰 Mimi Commented

⚖️ The zoo has mixed opinions. Some are concerned, some are fine with it. Please review each comment carefully and make the final call.


まあまあ、ほどほどに。

This mediation was peacefully delivered by nullvariant-ciel[bot]

@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@nullvariant nullvariant merged commit 9c64f4e into main Mar 30, 2026
29 checks passed
@nullvariant nullvariant deleted the fix/tooltip-markdown-escape branch March 30, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant