feat(ui): custom highlight rules (regex → color) - #58
Merged
Conversation
Browser-local highlight rules with regex patterns and color swatches. Matching lines render plain text with escaped <mark> spans; non-matching lines keep ANSI. Rules persist in localStorage (never server-side). Closes #30
Address PR review: select non-overlapping spans by rule order (not only start position), dedupe flag characters so duplicate flags do not throw, and cap scan length on huge lines.
ArianAr
commented
Jul 15, 2026
ArianAr
left a comment
Owner
Author
There was a problem hiding this comment.
Review
Summary: Custom highlight rules are solid on privacy (localStorage only) and XSS (HTML-escaped text + whitelist mark classes). Unit tests cover compile, escape, storage, and rendering.
Findings and disposition
| Severity | Issue | Status |
|---|---|---|
| bug | Overlap used start-greedy selection; nested matches could prefer a later rule | Fixed on branch (rule-order selection + test) |
| suggestion | Match-count guard ≠ full ReDoS protection | Accepted risk for client-only regex; scan capped at 16k chars |
| suggestion | JSON lines use JsonInspector (no inline marks) | Documented limitation; acceptable for v1 |
| nit | Duplicate flags (ii) could throw |
Fixed (dedupe in sanitizeHighlightFlags) |
| nit | markClass must stay static for XSS | Confirmed — colors from fixed options only |
Verdict: LGTM after fixes; merge when CI green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements roadmap v1.2.4 / issue #30.
papercut-highlight-rules); never sent to server<mark>spansTest plan
pnpm --filter @papercut/server test typecheck lint/error/i→ error color, confirm matches; reload persistenceCloses #30