Skip to content

[#325] restore permissive base64 decoding#326

Merged
lukasj merged 1 commit intojakartaee:masterfrom
laurentschoelens:gh-325
Feb 5, 2026
Merged

[#325] restore permissive base64 decoding#326
lukasj merged 1 commit intojakartaee:masterfrom
laurentschoelens:gh-325

Conversation

@laurentschoelens
Copy link
Contributor

Fixes #325

Regression from #309 and #282

If a character is not in base64 decoding map, it's ignored into the decoding process
newlines and spaces / tabulations or just ignored.

Restore previous base64 decoding function and protect code from throwing ArrayIndexOutOfBoundsException

@antoniosanct
Copy link
Contributor

This change has made the code intolerant of whitespace, which caused us some issues recently after upgrading.

Base64 encoding ignores whitespace so normally anything working with it is tolerant of it.

It might be good to modify this to allow for the case you are supporting without making whitespace something that isn't supported.

We fixed our issues by adding a whitespace filter.

I'm assuming that others will also be impacted by this.

Just an FYI, if this is intentional and you feel that enforcing whitespace is the right thing to do then that's fine. However from the commit message I assume you may not have realized the impact.

@laurentschoelens @lukasj Please, could your merge this PR ASAP?

Regards,
Antonio.

@laurentschoelens
Copy link
Contributor Author

This need to be merged by one of the repo owner, I've only provided the actual fix in that PR @antoniosanct

I'll try to reach someone if I can

@@ -711,8 +712,8 @@ private static int guessLength(String text) {
* because JIT can inline a lot of string access (with data of 1K chars, it was twice as fast)
*/
public static byte[] _parseBase64Binary(String text) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to not use the JDK-built in Base64 class? (avail since: 1.8)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should take a look but maybe base64 in jdk is more strict than here

@FDU-YSP
Copy link

FDU-YSP commented Dec 30, 2025

This is a bug in jakarta.xml.bind-api:4.0.4, and spring boot 3.5.8(to 4.0.1) picked this change. Why is this PR still open? Is the community unwilling to fix this bug? Our Spring Boot applications have already been affected by this bug.

@laurentschoelens
Copy link
Contributor Author

Hi @FDU-YSP

This should be merged by @lukasj at the beginning of 2026

In the meantime, did you try forcing jaxb-api to 4.0.2 version in your application ?

Regards

@laurentschoelens
Copy link
Contributor Author

See release notes from 4.0.3 and 4.0.4 here

@FDU-YSP
Copy link

FDU-YSP commented Dec 30, 2025

Hi @laurentschoelens, we just fallback spring-boot version to 3.5.6 to avoid this issue. In our framework, we have critical auth related component would use this issued method. So, for us, it is better to fallback to 3.5.6, which managed is jakarta.xml.bind-api: 4.0.2.

@laurentschoelens
Copy link
Contributor Author

This was also discussed here spring-projects/spring-boot#47242

@FDU-YSP
Copy link

FDU-YSP commented Dec 30, 2025

we also have the plan to upgarde our framework to spring boot 4.X, this PR is necessary for us. If the community do nothing, we have to build it with an internal artifact version to pick this change. Thanks for your PR !

@laurentschoelens
Copy link
Contributor Author

Pretty sure that will be done in january, february but not after.

Regards

@FDU-YSP
Copy link

FDU-YSP commented Jan 6, 2026

take a look on this PR every week

@FDU-YSP
Copy link

FDU-YSP commented Jan 30, 2026

looks still no update on this PR

@laurentschoelens
Copy link
Contributor Author

@FDU-YSP this should be merged really soon by now

@lukasj lukasj merged commit 4d531bd into jakartaee:master Feb 5, 2026
2 checks passed
@lukasj lukasj linked an issue Feb 5, 2026 that may be closed by this pull request
@laurentschoelens laurentschoelens deleted the gh-325 branch February 10, 2026 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatatypeConverterImpl._parseBase64Binary(text) fails if text contains whitespace fix #231 #282 has introduced a new bug

5 participants