Skip to content
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

Fix detection of parent directory in ModuleScopePlugin #2405

Merged
merged 2 commits into from
May 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/react-dev-utils/ModuleScopePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class ModuleScopePlugin {
// Maybe an indexOf === 0 would be better?
const relative = path.relative(appSrc, request.context.issuer);
// If it's not in src/ or a subdirectory, not our request!
if (relative[0] === '.') {
if (
relative.startsWith('../') ||
relative.startsWith('..\\')
) {
return callback();
}
// Find path from src to the requested file
Expand All @@ -49,7 +52,10 @@ class ModuleScopePlugin {
)
);
// Error if in a parent directory of src/
if (requestRelative[0] === '.') {
if (
requestRelative.startsWith('../') ||
requestRelative.startsWith('..\\')
) {
callback(
new Error(
`You attempted to import ${chalk.cyan(request.__innerRequest_request)} which falls outside of the project ${chalk.cyan('src/')} directory. ` +
Expand Down