-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bld): set product_string property in manifest to rename MacOS Hel…
…per apps (#1290) * Replace special and control characters iff options.app.name is a string Fixes: #1286
- Loading branch information
1 parent
a173040
commit b1caad7
Showing
6 changed files
with
34 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,25 +136,30 @@ async function globFiles({ | |
* @param {object} options - node manifest options | ||
* @param {string | string []} options.srcDir - src dir | ||
* @param {boolean} options.glob - glob flag | ||
* @returns {object} - Node manifest | ||
* @returns {Promise.<{path: string, json: object}>} - Node manifest | ||
*/ | ||
async function getNodeManifest({ | ||
srcDir, glob | ||
}) { | ||
let manifest; | ||
let manifest = { | ||
path: '', | ||
json: undefined, | ||
}; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ayushmanchhabra
Author
Collaborator
|
||
let files; | ||
if (glob) { | ||
files = await globFiles({ srcDir, glob }); | ||
for (const file of files) { | ||
if (path.basename(file) === 'package.json' && manifest === undefined) { | ||
manifest = JSON.parse(await fs.promises.readFile(file)); | ||
manifest.path = file; | ||
manifest.json = JSON.parse(await fs.promises.readFile(file)); | ||
} | ||
} | ||
} else { | ||
manifest = JSON.parse(await fs.promises.readFile(path.resolve(srcDir, 'package.json'))); | ||
manifest.path = path.resolve(srcDir, 'package.json'); | ||
manifest.json = JSON.parse(await fs.promises.readFile(path.resolve(srcDir, 'package.json'))); | ||
} | ||
|
||
if (manifest === undefined) { | ||
if (manifest.json === undefined) { | ||
throw new Error('package.json not found in srcDir file glob patterns.'); | ||
} | ||
|
||
|
@@ -220,8 +225,11 @@ export const parse = async (options, pkg) => { | |
|
||
options.app = options.app ?? {}; | ||
options.app.name = options.app.name ?? pkg.name; | ||
/* Remove special and control characters from app.name to mitigate potential path traversal. */ | ||
options.app.name = options.app.name.replace(/[<>:"/\\|?*\u0000-\u001F]/g, ''); | ||
/* Since the `parse` function is called twice, the first time `pkg` is `{}` and `options.app.name` is `undefined`. */ | ||
if (options.app.name) { | ||
/* Remove special and control characters from app.name to mitigate potential path traversal. */ | ||
options.app.name = options.app.name.replace(/[<>:"/\\|?*\u0000-\u001F]/g, ''); | ||
} | ||
options.app.icon = options.app.icon ?? undefined; | ||
|
||
// TODO(#737): move this out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change causes a lock from upcoming
manifest === undefined
condition test. Which prevents from detectingpackage.json
if using glob by any means.