Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Session JDBC JSON format invalid escape sequence #3299

Open
mindhaq opened this issue Dec 16, 2024 · 0 comments · May be fixed by #3316
Open

Spring Session JDBC JSON format invalid escape sequence #3299

mindhaq opened this issue Dec 16, 2024 · 0 comments · May be fixed by #3316
Labels
status: waiting-for-triage An issue we've not yet triaged type: bug A general bug

Comments

@mindhaq
Copy link

mindhaq commented Dec 16, 2024

Describe the bug

I want to store spring security session via JDBC in a Postgres database, and followed those instructions.

When the stored principal has an Umlaut in its name attribute (e.g. "Rüdiger"), storing SPRING_SECURITY_CONTEXT fails with an error like this:

[22P02] ERROR: invalid input syntax for type json Detail: Escape sequence "\3" is invalid. Where: JSON data, line 1: {"name":"R\3...

To Reproduce

The SQL for inserting/updating session attributes does not seem to work with those characters.

To reproduce, try this SQL containing the encode part from the suggested SQL in the spring-session documentation:

SELECT encode('{"name":"Rüdiger"}', 'escape')::jsonb;

Expected behavior

Storing non-ASCII characters in JSON fields should be possible.

Sample

Try the SQL above online here:

https://onecompiler.com/postgresql/4337htpct

@mindhaq mindhaq added status: waiting-for-triage An issue we've not yet triaged type: bug A general bug labels Dec 16, 2024
mindhaq added a commit to mindhaq/spring-session that referenced this issue Jan 7, 2025
mindhaq added a commit to mindhaq/spring-session that referenced this issue Jan 7, 2025
… encode() to insert JSON byte stream into PreparedStatement.

This works with session attributes containing special characters in the JSON blob.
@mindhaq mindhaq linked a pull request Jan 7, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant