spring-session icon indicating copy to clipboard operation
spring-session copied to clipboard

Spring Session JDBC JSON format invalid escape sequence

Open mindhaq opened this issue 1 year ago • 0 comments

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 avatar Dec 16 '24 09:12 mindhaq