File tree Expand file tree Collapse file tree
impl/src/main/java/com/sun/faces/application/view Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,6 +108,24 @@ public MultiViewHandler() {
108108 @ Override
109109 public void initView (FacesContext context ) throws FacesException {
110110 super .initView (context );
111+
112+ // Spec section 2.5.2.2 falls through to the session-based fallback when
113+ // neither <f:view contentType=charset=...> nor a request Content-Type
114+ // header charset yields an encoding. That session lookup is moot when
115+ // no session is created (e.g. stateless views or client side state saving).
116+ // When that happens, super.initView never calls setRequestCharacterEncoding
117+ // and the servlet container decodes form-data with its platform default
118+ // (often ISO-8859-1) — so a postback containing non-ASCII characters
119+ // (e.g. 'ä') can get corrupted on the way in. Default to the same encoding
120+ // that Util.getResponseEncoding() uses to render the page, so request
121+ // decoding at least matches what the page was rendered with.
122+ if (context .getExternalContext ().getRequestCharacterEncoding () == null ) {
123+ try {
124+ context .getExternalContext ().setRequestCharacterEncoding (Util .getResponseEncoding (context ));
125+ } catch (UnsupportedEncodingException e ) {
126+ throw new FacesException (e );
127+ }
128+ }
111129 }
112130
113131 /**
You can’t perform that action at this time.
0 commit comments