Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
d9bd3291
Unverified
Commit
d9bd3291
authored
Oct 19, 2021
by
Ionuț Botizan
Committed by
GitHub
Oct 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sanitize the path to the user config before importing (#30003)
parent
ac287e67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
config.ts
packages/next/server/config.ts
+5
-2
No files found.
packages/next/server/config.ts
View file @
d9bd3291
import
chalk
from
'chalk'
import
findUp
from
'next/dist/compiled/find-up'
import
{
basename
,
extname
,
relative
}
from
'path'
import
{
pathToFileURL
}
from
'url'
import
{
Agent
as
HttpAgent
}
from
'http'
import
{
Agent
as
HttpsAgent
}
from
'https'
import
*
as
Log
from
'../build/output/log'
...
...
@@ -530,8 +531,10 @@ export default async function loadConfig(
let
userConfigModule
:
any
try
{
// we must use file for absolute dynamic imports on Windows
userConfigModule
=
await
import
(
`file://
${
path
}
`
)
// `import()` expects url-encoded strings, so the path must be properly
// escaped and (especially on Windows) absolute paths must pe prefixed
// with the `file://` protocol
userConfigModule
=
await
import
(
pathToFileURL
(
path
).
href
)
}
catch
(
err
)
{
console
.
error
(
chalk
.
red
(
'Error:'
)
+
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment