URL encoded in url is erroneously parsed by webflow / EL / JSF

when I pass the character ... from the web page, the backend receives Γƒ. The webpage is part of the Spring Webflow / JSF1.2 / Facelets application. When I check POST with firebug, I see:

Content-Type: application/x-www-form-urlencoded Content-Length: 74 rapport=krediet_aanvragen&fw1=0&fw2=%C3%96ZTEKIN&fw3=0&fw4=0&zoeken=Zoeken 

The Γ– character is encoded as% C3% 96 using this table. I see that this is the correct hexadecimal representation of UTF-8 / Unicode character .... However, when it reaches the backend, the character changes to Γƒ. Using the same table, I see that somewhere there is code that tries to interpret C3 and 96 separately (or as a unicode \ u record). U + 00C3 turns out to be Γƒ, 96 is not a visible character, so this is explained.

Now I know that this is a typical case of coding mismatch, I just don't know where to look to fix this.

The web page contains

 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 

When debugging, I see that the library responsible for the wrong intervention is jboss-el 2.0.0.GA, which seems correct because the value is parsed for the backend in the webflow expression:

 <evaluate expression="rapportCriteria.addParameter('fw2', flowScope.fw2)" /> 

It is placed in flowScope:

 <evaluate expression="requestParameters.fw2" result="flowScope.fw2"/> 

Ignore the convective way to input the form into the backend, this is code that tries to integrate Webflow with BIRT reports ... but I have the same symptom in other web applications.

Any idea where I should start looking?

+4
source share
1 answer

I see that this is the correct hexadecimal representation of the UTF-8 / Unicode character .... However, when it reaches the backend, the character changes to Γƒ.

Thus, the client-side character encoding for encoding the POST body is correct, but the server-side character encoding for decoding the POST body is missing. You need to create a Filter that basically does the doFilter() method

 request.setCharacterEncoding("UTF-8"); 

and match it with the URL you’re interested in. Spring also already provides one of the fields, CharacterEncodingFilter , which basically matters above. All you have to do is add it to web.xml :

 <filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 

See also:


The HTML metadata header, by the way, is not related to the problem, it is ignored when the page is served via HTTP. This is the HTTP response header that instructs the webbrowser in which encoding it should display the response and send the parameters back to the server. Apparently, this is already set correctly, since the POST body is correctly encoded. The HTML HTML header is used only when the user saves the page to a local drive and iterates over it from the local drive.

+5
source

Source: https://habr.com/ru/post/1347063/


All Articles