pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Guo <guofenglinux@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: Assert failure with ICU support
Date: Thu, 20 Apr 2023 16:30:07 -0700
Message-ID: <fe9c75bafe422b9c672a037c8fa781cbcfef488d.camel@j-davis.com> (raw)
In-Reply-To: <3170490.1682020381@sss.pgh.pa.us>
References: <CAMbWs49Q6UoKGeT8pBkMtJGJd+16CBFZaaWUk9Du+2ERE5g_YA@mail.gmail.com>
	<ece303a3068026c6d6f10cab2a7f3f0836f4adb7.camel@j-davis.com>
	<3017542.1681937148@sss.pgh.pa.us>
	<c480b495be592d600504b99e70745ed8f43c877b.camel@j-davis.com>
	<3170490.1682020381@sss.pgh.pa.us>

On Thu, 2023-04-20 at 15:53 -0400, Tom Lane wrote:
> As I read it, it's meant to leave room for defining more escapes.
> If we allowed \x for any non-currently-defined "x" to just be "x",
> then there would be a compatibility problem if we wanted to make
> it mean something else.  But I think it's sufficient to reserve
> the ASCII letters for that purpose.

Sounds good, patch attached.

Regards,
	Jeff Davis

Attachments:

0001-Avoid-character-classification-in-regex-escape-parsi.patch (text/x-patch, 1.6K) download From b933b04d68cdac098c7eeb32b88707f3be385fe6 Mon Sep 17 00:00:00 2001 From: Jeff Davis <jeff@j-davis.com> Date: Thu, 20 Apr 2023 13:17:09 -0700 Subject: [PATCH] Avoid character classification in regex escape parsing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/backend/regex/regc_lex.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backend/regex/regc_lex.c b/src/backend/regex/regc_lex.c index 4780d79f09..38c09b1123 100644 --- a/src/backend/regex/regc_lex.c +++ b/src/backend/regex/regc_lex.c @@ -613,7 +613,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); @@ -755,8 +759,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); -- 2.34.1

view thread (8+ messages)  latest in thread

Message-ID: <fe9c75bafe422b9c672a037c8fa781cbcfef488d.camel@j-davis.com>
Permalink:  ../fe9c75bafe422b9c672a037c8fa781cbcfef488d.camel@j-davis.com/
Also on:    postgresql.org/message-id/fe9c75bafe422b9c672a037c8fa781cbcfef488d.camel@j-davis.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: pgsql@j-davis.com, tgl@sss.pgh.pa.us, guofenglinux@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Assert failure with ICU support
  In-Reply-To: <fe9c75bafe422b9c672a037c8fa781cbcfef488d.camel@j-davis.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox