Skip to content

Commit 80c0b12

Browse files
committed
fix(export): preserve unicode characters in workflow filenames
Previously, Non-ASCII characters (like Korean) in workflow names were replaced by dashes during export because of a restrictive regex. This update uses a Unicode-aware regex to allow letters and numbers from any language while still sanitizing unsafe filesystem characters. fixes #4119 Signed-off-by: JaeHyung Jang <jaehyung.jang@navercorp.com>
1 parent 4f40c4c commit 80c0b12

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @vitest-environment node
3+
*/
4+
import { describe, expect, it } from 'vitest'
5+
import { sanitizePathSegment } from './import-export'
6+
7+
describe('sanitizePathSegment', () => {
8+
it('should preserve ASCII alphanumeric characters', () => {
9+
expect(sanitizePathSegment('workflow-123_abc')).toBe('workflow-123_abc')
10+
})
11+
12+
it('should replace spaces with dashes', () => {
13+
expect(sanitizePathSegment('my workflow')).toBe('my-workflow')
14+
})
15+
16+
it('should replace special characters with dashes', () => {
17+
expect(sanitizePathSegment('workflow!@#')).toBe('workflow-')
18+
})
19+
20+
it('should preserve Korean characters (BUG REPRODUCTION)', () => {
21+
// This currently fails and returns '---'
22+
expect(sanitizePathSegment('한글')).toBe('한글')
23+
})
24+
25+
it('should preserve other Unicode characters', () => {
26+
expect(sanitizePathSegment('日本語')).toBe('日本語')
27+
})
28+
29+
it('should remove filesystem unsafe characters', () => {
30+
expect(sanitizePathSegment('work/flow?name*')).not.toContain('/')
31+
expect(sanitizePathSegment('work/flow?name*')).not.toContain('?')
32+
expect(sanitizePathSegment('work/flow?name*')).not.toContain('*')
33+
})
34+
})

apps/sim/lib/workflows/operations/import-export.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ export interface WorkspaceExportStructure {
4848
* Sanitizes a string for use as a path segment in a ZIP file.
4949
*/
5050
export function sanitizePathSegment(name: string): string {
51-
return name.replace(/[^a-z0-9-_]/gi, '-')
51+
return name
52+
.replace(/[^\p{L}\p{N}\-_]/gu, '-')
53+
.replace(/-+/g, '-')
54+
.trim()
5255
}
5356

5457
/**

0 commit comments

Comments
 (0)