aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2023-04-21 08:19:41 -0700
committerJeff Davis <jdavis@postgresql.org>2023-04-21 08:20:32 -0700
commitdde926b0f67d461f578e29c5505f21e0c710fba0 (patch)
treea2ded0ce4f796800ef87b6a8c72cf254507fb9db /src
parent6d60b718ceb09603eb26b6d6788b5c19c04ec5eb (diff)
downloadpostgresql-dde926b0f67d461f578e29c5505f21e0c710fba0.tar.gz
postgresql-dde926b0f67d461f578e29c5505f21e0c710fba0.zip
Avoid character classification in regex escape parsing.
For regex escape sequences, just test directly for the relevant ASCII characters rather than using locale-sensitive character classification. This fixes an assertion failure when a locale considers a non-ASCII character, such as "൧", to be a digit. Reported-by: Richard Guo Discussion: https://postgr.es/m/CAMbWs49Q6UoKGeT8pBkMtJGJd+16CBFZaaWUk9Du+2ERE5g_YA@mail.gmail.com Backpatch-through: 11
Diffstat (limited to 'src')
-rw-r--r--src/backend/regex/regc_lex.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/backend/regex/regc_lex.c b/src/backend/regex/regc_lex.c
index 826203e35d2..b3d3ff66f75 100644
--- a/src/backend/regex/regc_lex.c
+++ b/src/backend/regex/regc_lex.c
@@ -616,7 +616,11 @@ lexescape(struct vars *v)
assert(!ATEOS());
c = *v->now++;
- if (!iscalnum(c))
+
+ /* if it's not alphanumeric ASCII, treat it as a plain character */
+ if (!('a' <= c && c <= 'z') &&
+ !('A' <= c && c <= 'Z') &&
+ !('0' <= c && c <= '9'))
RETV(PLAIN, c);
NOTE(REG_UNONPOSIX);
@@ -758,8 +762,11 @@ lexescape(struct vars *v)
RETV(PLAIN, c);
break;
default:
- assert(iscalpha(c));
- FAILW(REG_EESCAPE); /* unknown alphabetic escape */
+ /*
+ * Throw an error for unrecognized ASCII alpha escape sequences,
+ * which reserves them for future use if needed.
+ */
+ FAILW(REG_EESCAPE);
break;
}
assert(NOTREACHED);