Fix escapeAttr XSS, ExtensionAuth double fetch, and candidate page title#248
Fix escapeAttr XSS, ExtensionAuth double fetch, and candidate page title#248
Conversation
…didate page title - #244: Escape `&` to `&` before other replacements in escapeAttr() - #243: Remove `error` from useEffect dependency array to prevent double POST on token fetch failure - #242: Use stored tab title from chrome.tabs.query instead of popup's document.title for candidate "Track this" button Closes #242, closes #243, closes #244 https://claude.ai/code/session_01AmZyEy5PWRPk34fqgyyUQ9
Move pure utility functions from popup.ts into popup/utils.ts for testability. Add comprehensive test coverage for escapeAttr (including ampersand escaping) and sanitizeTier. Move import to top of file following codebase conventions. https://claude.ai/code/session_01AmZyEy5PWRPk34fqgyyUQ9
- Add error check to useEffect guard to prevent implicit retries when user object reference changes after a failed token fetch - Add comment documenting KNOWN_TIERS sync dependency on shared/models/auth.ts TIER_LIMITS https://claude.ai/code/session_01AmZyEy5PWRPk34fqgyyUQ9
Version bump for popup bug fixes: escapeAttr ampersand encoding, candidate page title source, and utils module extraction. https://claude.ai/code/session_01AmZyEy5PWRPk34fqgyyUQ9
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes three browser extension and extension auth bugs reported in issues #242, #243, and #244. The
escapeAttrfunction was missing ampersand escaping (XSS vector), the ExtensionAuth page fired duplicate POST requests on token fetch failure, and the candidate "Track this" button used the popup's owndocument.titleinstead of the target page's title.Additionally hardens the ExtensionAuth error guard, extracts popup utilities into a testable module with 10 new tests, and rebuilds the extension ZIP as v1.0.3.
Changes
Bug fixes:
escapeAttrnow escapes&to&before other entity replacements, preventing HTML attribute injection (Bug: escapeAttr does not escape ampersand in popup HTML attributes #244)errorfromuseEffectdependency array in ExtensionAuth to prevent double POST on token fetch failure (Bug: ExtensionAuth useEffect fires twice on token fetch failure #243)errorto the early-return guard to prevent implicit retries whenuserobject reference changestab.titlefromchrome.tabs.queryinstead of the popup'sdocument.title(Bug: Candidate 'Track this' button uses popup document.title instead of target page title #242)Refactoring:
escapeAttrandsanitizeTierintoextension/src/popup/utils.tsfor testabilityKNOWN_TIERSreferencingshared/models/auth.tsTests:
extension/src/popup/utils.test.tswith 10 tests covering escapeAttr edge cases and sanitizeTierExtension release:
fetchthechange-extension.zipCloses #242, closes #243, closes #244
How to test
npm run check && npm run test— 62 test files, 1717 tests passextension/fetchthechange-extension.zip) in Chrome&in the title, open popup, click "Track this" on a candidate — verify the monitor name input shows the correct page title with ampersands displayed properly/extension-authwhile the token endpoint is returning errors — verify only one POST request is made (check Network tab)https://claude.ai/code/session_01AmZyEy5PWRPk34fqgyyUQ9