-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Description
Description:
The isRelativeURL function contains a flawed regex pattern that incorrectly identifies certain URLs, leading to three failing test cases and potential security vulnerabilities.

Steps to reproduce:
- Run the test suite:
apps/meteor/tests/unit/lib/utils/isRelativeURL.spec.ts - Observe three failing test cases marked with
// TODOcomments
Expected behavior:
- Simple relative paths like
'test'should returntrue(relative to current directory) - Directory references like
'.'and'..'should returntrue - Absolute URIs with schemes (e.g.,
data:,https:,javascript:) should returnfalse - Paths starting with
/should returntrue(root-relative paths) - Paths like
./testand../testshould returntrue(already working)
Actual behavior:
Three testcases fail
Server Setup Information:
- Operating System: Linux
- NodeJS Version: 22.16.0
Proposed Solution
The regex should be updated to:
- Check if the URL contains a protocol scheme (e.g.,
protocol:) and returnfalseif it does - Return
truefor paths without schemes (including simple filenames,.,..,/path,./path,../path)
A proper implementation should use URL parsing logic rather than regex, or at minimum, explicitly reject strings matching the pattern [a-zA-Z][a-zA-Z\d+\-.]*: which indicates an absolute URI with a scheme.
Reactions are currently unavailable