Store response encoding during initial request. #5542
Closed
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.
This is a proposal to resolve #5543
Version 4.0.6 introduces a change (fault?) in behavior, which breaks character encoding detection under some circumstances. I think the change was introduced in #5385.
Originally, the FaceletViewHandlingStrategy had this line (
sessionMap.put(CHARACTER_ENCODING_KEY, encoding);
), which stored the response encoding into the external context session. The stored encoding could then be taken into account during next request in theViewHandler
:mojarra/impl/src/main/java/jakarta/faces/application/ViewHandler.java
Line 389 in 263095b
Storing the response encoding is I think in line with spec section "2.5.2.2. Determining the Character Encoding" (https://jakarta.ee/specifications/faces/4.0/jakarta-faces-4.0#determining-the-character-encoding), which mentions:
The mentioned PR added the storing of the encoding to ViewHandler:
https://github.com/eclipse-ee4j/mojarra/pull/5385/files#diff-6903369dd9e9cf64f15a5126c3d098577e81cb1dc05c760c6586d827966268beR235
but that IMO is not the right place in the lifecycle, or at least it doesn't have the same effect. In my case it's not executed as the encoding at that point is null.
The reproducer for this is a page containing a simple form:
When you enter an accented character into the input and press the button, the output field should display the character. With the version 4.0.6+ the encoding gets mangled, character is not displayed correctly.