Skip to content

fix(editor): Solve the problem of non-English characters displaying "_" when downloading workflows #16116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

luka-mimi
Copy link
Contributor

@luka-mimi luka-mimi commented Jun 7, 2025

Summary

Solve the problem of non-English characters displaying "_" when downloading workflows

Related Linear tickets, Github issues, and Community forum posts

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ luka-mimi
❌ luka


luka seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic reviewed 1 file and found no issues. Review PR in cubic.dev.

@luka-mimi luka-mimi changed the title fix(editor): Fixed the issue that the downloaded workflow json file name is incomplete fix(editor): Solve the problem of non-English characters displaying "_" when downloading workflows Jun 7, 2025
@luka-mimi
Copy link
Contributor Author

name = name.replace(
  /[^a-zA-Z0-9\u4e00-\u9fa5\uAC00-\uD7A3\u3040-\u30FF\u0E00-\u0E7F\u0600-\u06FF\u0370-\u03FF\u0400-\u04FF\u0100-\u017F._-]/g,
  '_'
).replace(/^\.+/, '_');

🔹 First .replace(...)

/[^a-zA-Z0-9\u4e00-\u9fa5\uAC00-\uD7A3\u3040-\u30FF\u0E00-\u0E7F\u0600-\u06FF\u0370-\u03FF\u0400-\u04FF\u0100-\u017F._-]/g

This regular expression matches any character that is NOT in the allowed set. Here's what it allows:

✅ Allowed Characters:

  • a-zA-Z0-9: All English letters (upper and lower case) and digits
  • \u4e00-\u9fa5: Simplified Chinese characters
  • \uAC00-\uD7A3: Korean Hangul syllables
  • \u3040-\u30FF: Japanese Hiragana and Katakana
  • \u0E00-\u0E7F: Thai characters
  • \u0600-\u06FF: Arabic characters
  • \u0370-\u03FF: Greek characters
  • \u0400-\u04FF: Cyrillic characters (e.g., Russian, Ukrainian)
  • \u0100-\u017F: Latin Extended-A (e.g., letters with accents like Ā, Č, etc.)
  • .: a dot (period) — allowed
  • _: an underscore — allowed
  • -: a hyphen — allowed

⚠️ Replaced:

Anything outside of these ranges is replaced with an underscore (_).


🔹 Second .replace(...)

/^\.+/

This matches one or more dots at the start of the string (i.e., leading dots). It's used to sanitize filenames that start with . (e.g., .env or .hidden files).

  • ^: beginning of the string
  • \.+: one or more literal dots

⚠️ Replaced:

Any leading dots are replaced with a single underscore _, to avoid hidden/system file behavior on UNIX-like systems.


🔚 Summary

This code:

  1. Replaces all invalid characters (not in approved multilingual ranges + safe symbols) with _.
  2. Replaces leading dots with _ to prevent system file behavior.

Used mainly for filename sanitization across different languages and OSes.

@n8n-assistant n8n-assistant bot added community Authored by a community member in linear Issue or PR has been created in Linear for internal review labels Jun 7, 2025
@Joffcom
Copy link
Member

Joffcom commented Jun 7, 2025

Hey @luka-mimi,

Thanks for the PR, We have created "GHC-2404" as the internal reference to get this reviewed.

One of us will be in touch if there are any changes needed, in most cases this is normally within a couple of weeks but it depends on the current workload of the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member in linear Issue or PR has been created in Linear for internal review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants