Skip to content

Commit

Permalink
Restrict the URN end characters to relatively safe ASCII characters
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurswag committed May 17, 2024
1 parent dad0c36 commit c475bef
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions backend/library/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@

logger = structlog.get_logger(__name__)

URN_REGEX = r"^urn:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)(?::([a-zA-Z0-9_-]+))?:(\S+)$"

URN_REGEX = r"^urn:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)(?::([a-zA-Z0-9_-]+))?:([0-9A-Za-z\[\]\(\)\-\._:]+)$"

def match_urn(urn_string):
match = re.match(URN_REGEX, urn_string)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const UUID_REGEX = '([0-9a-f]{8}\\-[0-9a-f]{4}\\-[0-9a-f]{4}\\-[0-9a-f]{4
export const UUID_LIST_REGEX = new RegExp(`^${UUID_REGEX}(,${UUID_REGEX})*$`);

export const URN_REGEX =
/^urn:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)(?::([a-zA-Z0-9_-]+))?:(\S+)$/;
/^urn:([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)(?::([a-zA-Z0-9_-]+))?:([0-9A-Za-z\[\]\(\)\-\._:]+)$/;

export const LOCALE_DISPLAY_MAP = {
en: '🇬🇧 English',
Expand Down

0 comments on commit c475bef

Please sign in to comment.