GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: validate Unicode escapes of PostgreSQL escape strings by tanjiroK-coder · Pull Request #2861 · JSQLParser/JSqlParser

Conversation

@tanjiroK-coder

@tanjiroK-coder tanjiroK-coder commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

With Dialect.POSTGRESQL, StringValue.getNotExcapedValue resolves the \uXXXX and \UXXXXXXXX escapes of an E'...' string with Integer.parseInt and StringBuilder.appendCodePoint, with no range or surrogate check, while the U&'...' path added in #2820 already validates the same escapes the way the server does. So E'\uD800' comes back as a lone surrogate (an ill-formed string that turns into U+FFFD or '?' once it is encoded), E'\u0000' yields a NUL the server refuses, E'\U00110000' throws from StringBuilder, E'\UFFFFFFFF' throws NumberFormatException, and the parser accepts every one of them. I noticed it while comparing the two decoders after the U&'' change. The E'' Unicode escapes now go through the same code point and surrogate pair rules as the U&'' escapes: a pair must be two consecutive escapes, in either form, and too few digits, code point zero, anything above U+10FFFF and an unpaired surrogate raise the documented IllegalArgumentException. stringValue() in the grammar checks an escape string under the PostgreSQL dialect the way lexUnicodeEscapeString does for U&'' strings, so such a literal is a parse error as on the server. Standard strings and the other dialects are unchanged, and the regression test in StringValueTest covers the accepted and rejected forms.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tanjiroK-coder
fix: validate Unicode escapes of PostgreSQL escape strings
9d297a0
With Dialect.POSTGRESQL, StringValue.getNotExcapedValue resolved the
\uXXXX and \UXXXXXXXX escapes of an E'...' string with Integer.parseInt
and StringBuilder.appendCodePoint and no range or surrogate check, so
E'\uD800' produced an unpaired surrogate, E'\u0000' a NUL, E'\U00110000'
threw from StringBuilder and E'\UFFFFFFFF' a NumberFormatException,
while the parser accepted them all. PostgreSQL rejects each of them.

Decode the E'' Unicode escapes with the rules the U&'' path already
applies: exactly 4 or 8 hexadecimal digits, no code point zero or value
above U+10FFFF, and a surrogate pair only as two consecutive escapes.
The parser rejects such a literal under the PostgreSQL dialect as it
does for U&'' strings.
@manticore-projects
manticore-projects merged commit 23d3173 into JSQLParser:master Oct 27, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects

manticore-projects commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Thank you very much!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@tanjiroK-coder @manticore-projects
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.