Skip to content

Commit c0f1b5c

Browse files
authored
fix(gatsby-plugin-sharp): Sanitize tmp filename (#29246)
1 parent 94936fb commit c0f1b5c

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

packages/gatsby-plugin-sharp/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"async": "^3.2.0",
1212
"bluebird": "^3.7.2",
1313
"fs-extra": "^9.1.0",
14+
"filenamify": "^4.2.0",
1415
"gatsby-core-utils": "^1.10.0-next.0",
1516
"gatsby-telemetry": "^1.10.0-next.1",
1617
"got": "^10.7.0",

packages/gatsby-plugin-sharp/src/trace-svg.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
const { promisify } = require(`bluebird`)
22
const _ = require(`lodash`)
33
const tmpDir = require(`os`).tmpdir()
4+
const path = require(`path`)
45
const sharp = require(`./safe-sharp`)
5-
6+
const filenamify = require(`filenamify`)
67
const duotone = require(`./duotone`)
78
const { getPluginOptions, healOptions } = require(`./plugin-options`)
89
const { reportError } = require(`./report-error`)
@@ -109,7 +110,12 @@ exports.notMemoizedtraceSVG = async ({ file, args, fileArgs, reporter }) => {
109110

110111
const optionsHash = createContentDigest(options)
111112

112-
const tmpFilePath = `${tmpDir}/${file.internal.contentDigest}-${file.name}-${optionsHash}.${file.extension}`
113+
const tmpFilePath = path.join(
114+
tmpDir,
115+
filenamify(
116+
`${file.internal.contentDigest}-${file.name}-${optionsHash}.${file.extension}`
117+
)
118+
)
113119

114120
try {
115121
await exports.memoizedPrepareTraceSVGInputFile({

yarn.lock

+10-1
Original file line numberDiff line numberDiff line change
@@ -11118,6 +11118,15 @@ filenamify@^2.0.0:
1111811118
strip-outer "^1.0.0"
1111911119
trim-repeated "^1.0.0"
1112011120

11121+
filenamify@^4.2.0:
11122+
version "4.2.0"
11123+
resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-4.2.0.tgz#c99716d676869585b3b5d328b3f06590d032e89f"
11124+
integrity sha512-pkgE+4p7N1n7QieOopmn3TqJaefjdWXwEkj2XLZJLKfOgcQKkn11ahvGNgTD8mLggexLiDFQxeTs14xVU22XPA==
11125+
dependencies:
11126+
filename-reserved-regex "^2.0.0"
11127+
strip-outer "^1.0.1"
11128+
trim-repeated "^1.0.0"
11129+
1112111130
1112211131
version "3.5.11"
1112311132
resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.5.11.tgz#1919326749433bb3cf77368bd158caabcc19e9ee"
@@ -23945,7 +23954,7 @@ strip-json-comments@^3.0.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1
2394523954
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
2394623955
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
2394723956

23948-
strip-outer@^1.0.0:
23957+
strip-outer@^1.0.0, strip-outer@^1.0.1:
2394923958
version "1.0.1"
2395023959
resolved "https://registry.yarnpkg.com/strip-outer/-/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631"
2395123960
dependencies:

0 commit comments

Comments
 (0)