-
Notifications
You must be signed in to change notification settings - Fork 13.1k
fix: isRelativeURL function logic and edge cases
#38606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix: isRelativeURL function logic and edge cases
#38606
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughThe isRelativeURL utility was updated to invert its regex logic: it now treats strings with protocol schemes or leading Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. No actionable comments were generated in the recent review. 🎉 📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
✏️ Tip: You can disable this entire section by setting 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
Proposed changes (including videos or screenshots)
Fixed the
isRelativeURLfunction to correctly identify relative URLs and prevent potential security vulnerabilities.Changes:
isRelativeURLto properly detect absolute URIs with protocol schemestruefor simple relative paths (test,.,..)falsefor absolute URIs with schemes (data:,javascript:,https:, etc.)Issue(s)
Fixes #38605
Steps to test or reproduce
Run the mocha unit tests:
cd apps/meteor yarn mocha --config .mocharc.js tests/unit/lib/utils/isRelativeURL.spec.tsVerify all test cases pass, particularly:
testreturns true (simple relative path).returns true (current directory)..returns true (parent directory)data:image/gif;base64,...returns false (data URI)javascript:alert(1)returns false (javascript protocol - security)https://rocket.chatreturns false (absolute URL)//rocket.chatreturns false (protocol-relative URL)Summary by CodeRabbit
Bug Fixes
Tests
Chores