Skip to content

Commit

Permalink
fix: validate invisible characters
Browse files Browse the repository at this point in the history
  • Loading branch information
KUN1007 committed Jan 4, 2025
1 parent 2b3ff71 commit 2cc7be5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kun-galgame-nuxt3",
"version": "2.19.26",
"version": "2.19.27",
"packageManager": "[email protected]",
"private": true,
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions utils/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export const isValidEmail = (email: string) => {
}

export const isValidName = (name: string) => {
const invisibleCharRegex =
/[\x09\x20\xA0\xAD\u034F\u061C\u115F\u1160\u17B4\u17B5\u180E\u2000-\u200F\u202F\u205F\u2060-\u206F\u3000\u2800\u3164\uFEFF\uFFA0\uD800-\uDBFF\uDC00-\uDFFF\u1D159\u1D173-\u1D179\u1D17A\uE0020]+/g

Check failure on line 24 in utils/validate.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected control character(s) in regular expression: \x09

Check failure on line 24 in utils/validate.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected combined character in character class

Check failure on line 24 in utils/validate.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected combined character in character class

Check failure on line 24 in utils/validate.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected surrogate pair in character class. Use 'u' flag
if (invisibleCharRegex.test(name)) {
return false
}
const regex = /^[\p{L}\p{N}!~_@#$%^&*()+=-]{1,17}$/u
return regex.test(name)
}
Expand Down

0 comments on commit 2cc7be5

Please sign in to comment.