Skip to content

Commit f83f05f

Browse files
authored
fix(mac): normalize filename to NFD form (#7901)
1 parent 3b3a698 commit f83f05f

4 files changed

Lines changed: 18 additions & 6 deletions

File tree

.changeset/thick-flowers-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
fix codesign and DMG layout when productName or executableName contains Unicode

packages/app-builder-lib/src/appInfo.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ export class AppInfo {
3232
readonly sanitizedProductName: string
3333
readonly productFilename: string
3434

35-
constructor(private readonly info: Packager, buildVersion: string | null | undefined, private readonly platformSpecificOptions: PlatformSpecificBuildOptions | null = null) {
35+
constructor(
36+
private readonly info: Packager,
37+
buildVersion: string | null | undefined,
38+
private readonly platformSpecificOptions: PlatformSpecificBuildOptions | null = null,
39+
normalizeNfd = false
40+
) {
3641
this.version = info.metadata.version!
3742

3843
if (buildVersion == null) {
@@ -63,10 +68,10 @@ export class AppInfo {
6368
}
6469

6570
this.productName = info.config.productName || info.metadata.productName || info.metadata.name!
66-
this.sanitizedProductName = sanitizeFileName(this.productName)
71+
this.sanitizedProductName = sanitizeFileName(this.productName, normalizeNfd)
6772

6873
const executableName = platformSpecificOptions?.executableName ?? info.config.executableName
69-
this.productFilename = executableName != null ? sanitizeFileName(executableName) : this.sanitizedProductName
74+
this.productFilename = executableName != null ? sanitizeFileName(executableName, normalizeNfd) : this.sanitizedProductName
7075
}
7176

7277
get channel(): string | null {

packages/app-builder-lib/src/macPackager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export default class MacPackager extends PlatformPackager<MacConfiguration> {
5858

5959
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6060
protected prepareAppInfo(appInfo: AppInfo): AppInfo {
61-
return new AppInfo(this.info, this.platformSpecificBuildOptions.bundleVersion, this.platformSpecificBuildOptions)
61+
// codesign requires the filename to be normalized to the NFD form
62+
return new AppInfo(this.info, this.platformSpecificBuildOptions.bundleVersion, this.platformSpecificBuildOptions, true)
6263
}
6364

6465
async getIconPath(): Promise<string | null> {

packages/app-builder-lib/src/util/filename.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import * as _sanitizeFileName from "sanitize-filename"
33
import * as path from "path"
44

5-
export function sanitizeFileName(s: string): string {
6-
return _sanitizeFileName(s)
5+
export function sanitizeFileName(s: string, normalizeNfd = false): string {
6+
const sanitized = _sanitizeFileName(s)
7+
return normalizeNfd ? sanitized.normalize("NFD") : sanitized
78
}
89

910
// Get the filetype from a filename. Returns a string of one or more file extensions,

0 commit comments

Comments
 (0)