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

JsonMapObjectReaderWriter not escaping the characters like \n properly #900

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

juniiorviani
Copy link

Issue ref: https://issues.apache.org/jira/browse/CXF-8651

The JWS is generate with an invalid payload if I try to set a claim like this:

JwtClaims claims = new JwtClaims();

String claim = "GET\n\n\nWed, 19 Jan 2022 15:25:29 GMT\n/test/16c8a1ec-8d75-47a1-b138-46746713b8d8";
claims.setClaim("test", claim);

JwsCompactProducer jwsProducer = new JwsJwtCompactProducer(claims);

The JWS payload result will be: eyJ0ZXN0IjoiR0VUCgoKV2VkLCAxOSBKYW4gMjAyMiAxNToyNToyOSBHTVQKL3Rlc3QvMTZjOGExZWMtOGQ3NS00N2ExLWIxMzgtNDY3NDY3MTNiOGQ4In0

And when I decode the result is:
"{"test":"GET\n\n\nWed, 19 Jan 2022 15:25:29 GMT\n/test/16c8a1ec-8d75-47a1-b138-46746713b8d8"}"

This is an invalid payload because the json is stringify.. the json should be:

{ "test" : "GET\n\n\nWed, 19 Jan 2022 15:25:29 GMT\n/test/16c8a1ec-8d75-47a1-b138-46746713b8d8" }

- the strings is now properly escaped
@amarkevich
Copy link
Contributor

@juniiorviani could you add a unit test for this case?

@juniiorviani
Copy link
Author

juniiorviani commented Feb 7, 2022

Sure thing, @amarkevich I just added the unit tests

@coheigea
Copy link
Contributor

The tests are failing in this module, and checkstyle as well:

[ERROR] Failures:
[ERROR] JsonMapObjectReaderWriterTest.testAlreadyEscapedBackslash:210 expected:<a[]> but was:<a[]>
[ERROR] JsonMapObjectReaderWriterTest.testAlreadyEscapedDoubleQuotes:174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants