Skip to content

fix(drizzle): allow unicode characters in JSON query values#3

Merged
deepshekhardas merged 1 commit into
mainfrom
fix/unicode-string-regex
May 19, 2026
Merged

fix(drizzle): allow unicode characters in JSON query values#3
deepshekhardas merged 1 commit into
mainfrom
fix/unicode-string-regex

Conversation

@deepshekhardas

@deepshekhardas deepshekhardas commented May 19, 2026

Copy link
Copy Markdown
Owner

Description

The SAFE_STRING_REGEX was using \w which only matches ASCII characters ([A-Za-z0-9_]), blocking any non-ASCII characters (CJK, accented Latin, emoji, etc.) in JSON field queries.

Fix

Changed to use \p{L} (Unicode letter) and \p{N} (Unicode number) with the /u flag, which allows international text while still blocking SQL metacharacters (' , ; -- ( ) = / \ etc.).

Testing

This fix allows JSON field queries with:

  • Chinese characters (中文)
  • Japanese characters (日本語)
  • Korean characters (한국어)
  • Accented Latin (é, ü, ñ)
  • Emoji and other Unicode characters

While still blocking SQL injection attempts.

Fixes: payloadcms#16401


Summary by cubic

Fix JSON field queries to accept Unicode text by updating the safe string regex in drizzle, while keeping SQL injection protections intact. Fixes payloadcms#16401.

  • Bug Fixes
    • Updated SAFE_STRING_REGEX to /^[\p{L}\p{N}\s @.\-+:_]*$/u (replacing \w) to allow CJK, accents, and emoji while blocking SQL metacharacters.

Written for commit 83e8c42. Summary will update on new commits. Review in cubic

The SAFE_STRING_REGEX was using \w which only matches ASCII characters,
blocking any non-ASCII characters (CJK, accented Latin, emoji, etc.) in
JSON field queries.

Changed to use \p{L} (Unicode letter) and \p{N} (Unicode number) with
the /u flag, which allows international text while still blocking SQL
metacharacters (' , ; -- ( ) = / \ etc.).

Fixes: payloadcms#16401
@deepshekhardas deepshekhardas merged commit fb4ea4d into main May 19, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SAFE_STRING_REGEX in escapeSQLValue rejects all non-ASCII characters, breaking JSON field queries with Unicode values

1 participant