From 0454e05a0094165fdd2033b90be129ac4c98205f Mon Sep 17 00:00:00 2001 From: Teah Kaasa Mclean <tkm@marley.uio.no> Date: Tue, 22 Aug 2023 11:49:50 +0200 Subject: [PATCH] Added hyphen to allowed characters in valid names --- frontend/src/utils/index.ts | 3 ++- greg/utils.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index d85c7f3f..90854e45 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -125,6 +125,7 @@ function stringContainsIllegalChars(string: string): boolean { // Only allow the following characters: // ----- Basic Latin ----- // U+0020 (Space) + // U+002D (Hyphen-minus) // U+0041 - U+005A (Latin Alphabet: Uppercase) // U+0061 - U+007A (Latin Alphabet: Lowercase) // ----- Latin-1 Supplement ----- @@ -136,7 +137,7 @@ function stringContainsIllegalChars(string: string): boolean { // U+0100 - U+017F (European Latin) // eslint-disable-next-line no-control-regex - return /[^\u0020\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u017F]/g.test( + return /[^\u0020\u002D\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u017F]/g.test( string ) } diff --git a/greg/utils.py b/greg/utils.py index b60d9b94..63e17472 100644 --- a/greg/utils.py +++ b/greg/utils.py @@ -226,6 +226,7 @@ def string_contains_illegal_chars(string: str) -> bool: # Only allow the following characters: # ----- Basic Latin ----- # U+0020 (Space) + # U+002D (Hyphen-minus) # U+0041 - U+005A (Latin Alphabet: Uppercase) # U+0061 - U+007A (Latin Alphabet: Lowercase) # ----- Latin-1 Supplement ----- @@ -237,7 +238,7 @@ def string_contains_illegal_chars(string: str) -> bool: # U+0100 - U+017F (European Latin) return bool( re.search( - r"[^\u0020\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u017F]", + r"[^\u0020\u002D\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u017F]", string, ) ) -- GitLab