File tree 2 files changed +9
-2
lines changed 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ const Logger = require('./Logger');
14
14
const analyzer = require ( './analyzer' ) ;
15
15
16
16
const projectRoot = path . resolve ( __dirname , '..' ) ;
17
+ const assetsRoot = path . join ( projectRoot , 'public' ) ;
17
18
18
19
module . exports = {
19
20
startServer,
@@ -169,7 +170,13 @@ async function generateReport(bundleStats, opts) {
169
170
}
170
171
171
172
function getAssetContent ( filename ) {
172
- return fs . readFileSync ( `${ projectRoot } /public/${ filename } ` , 'utf8' ) ;
173
+ const assetPath = path . join ( assetsRoot , filename ) ;
174
+
175
+ if ( ! assetPath . startsWith ( assetsRoot ) ) {
176
+ throw new Error ( `"${ filename } " is outside of the assets root` ) ;
177
+ }
178
+
179
+ return fs . readFileSync ( assetPath , 'utf8' ) ;
173
180
}
174
181
175
182
/**
Original file line number Diff line number Diff line change 4
4
< %- escapeScript (assetContent (filename)) % >
5
5
< / script>
6
6
< % } else { % >
7
- < script src= " / <%= filename %>" >< / script>
7
+ < script src= " <%= filename %>" >< / script>
8
8
< % } %>
You can’t perform that action at this time.
0 commit comments