Encoding problem when using german umlaute in uri parameters

Hi,

I’m facing a serious problem passing my application some parameters over the url.

An example for such a url would be:
http://localhost:8080/wettbewerberumfeld.web/#!/radius=300&place=münchen&street=Wörthstraße 12

As you can see the parameters can contain german umlaute, because they are used as input for an geocoding application to show the exact location on a map. In the MapView the parameters are parsed and extracted to display the map.
When calling the application with the above url I receive the follwoing Exception:

 java.lang.RuntimeException: Invalid location URI received from client
at com.vaadin.server.Page.init(Page.java:645)
at com.vaadin.ui.UI.doInit(UI.java:611)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:223)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:73)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1371)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.net.URISyntaxException: Illegal character in fragment at index 83: http://localhost:8080/urlparameters/#!/radius=300&place=münchen&street=Wörthstraße 12
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parse(URI.java:3048)
at java.net.URI.<init>(URI.java:595)
at com.vaadin.server.Page.init(Page.java:643)
... 23 more

Nov 20, 2013 3:27:21 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Url Parameter Test]
 in context with path 
[/urlparameters] threw exception [com.vaadin.server.ServiceException: java.lang.RuntimeException: Invalid location URI received from client]
 with root cause
java.net.URISyntaxException: Illegal character in fragment at index 83: http://localhost:8080/urlparameters/#!/radius=300&place=münchen&street=Wörthstraße 12
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.checkChars(URI.java:3002)
at java.net.URI$Parser.parse(URI.java:3048)
at java.net.URI.<init>(URI.java:595)
at com.vaadin.server.Page.init(Page.java:643)
at com.vaadin.ui.UI.doInit(UI.java:611)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:223)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:73)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1371)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

As you can see the server receives a malformed url which he cannot parse: http://localhost:8080/urlparameters/#!/radius=300&place=münchen&street=Wörthstraße 12

To reproduce this error I have written a simple example application with a View which displays the received event.getParameters() in a Label. This View has the following code for it’s enter-method:

@Override
    public void enter(ViewChangeEvent event) {
        
        final String parameters = event.getParameters();
        
        if (parameters == null
                || event.getParameters().equals("")) {
            
            this.label_1.setValue(KEINE_URI_PARAMETER_GEFUNDEN);
            
        }else{
                this.label_1.setValue(parameters);
        }
  }

While testing with this example application I noticed the following effects:

  1. Calling the view the first time with the url http://localhost:8080/urlparameters/#!/place=münchen, the parameter string is correctly displayed as: place=münchen
  2. Calling the url the second time:
    [list=1]
  3. The displayed String is: place=münchen
  4. And the url changes to: http://localhost:8080/urlparameters/#!/place=münchen

    [/list]
  5. Calling the url http://localhost:8080/urlparameters/#!/radius=300&place=münchen&street=Wörthstraße 12 the first time (yes with space between street and streetno)
    [list=1]
  6. The displayed string is: radius=300&place=münchen&street=Wörthstraße 12
  7. Url still the original

    [/list]
  8. Calling the url again or reloading:
    [list=1]
  9. I get the above exception

    [/list]

The whole process was executed in Chrome and IE9 on a Tomcat 7.0.11.1.
I have also tried the tomcat options mentioned here:
http://wiki.apache.org/tomcat/FAQ/CharacterEncoding

No success.
I also debugged the vaadinBootstrap.js until the request is send to the server component and in js the url-encoding is correct.

Is this a vaadin bug or I’m doing something wrong?
A work around or help is very much appreciated.

Thanks in advance!
Armin

Hi, which Vaadin version are you using? At least one URI fragment double encoding issue was fixed in 7.0.5; this might well be different but it never hurts to check.

Although “place=münchen&street=Wörthstraße 12” looks like it tries to interpret UTF-8 text as ISO 8859.

IIRC Tomcat has also had some issues with the different encodings, could you try out the newest version 7.0.42?

Hi,
we are using Vaadin 7.1.0 and in the example app I’m using version 7.1.8.
Same behaviour in both versions.

I will try Tomcat 7.0.42 with the example app and give a short feedback. In production we are stuck with 7.0.11 because of ntlm for authentification. But I’ll give it a try.

Just a quick reminder that the quoted only appears the after reloding or calling the url for the second time. When handling the first request everything works fine.

Thanks for the quick response!
Armin

So, I tried Tomcat 7.0.47 with and without URIEncoding and useBodyEncodingForURI. No change in behaviour. Problem(s) still exist and are reproduceable.

Best regards
Armin

Anybody any ideas? Help is still appreciated.

Probably a bit too late but this worked for me:

tmpUsername = URLDecoder.decode(new String(paramsMap.get(URL_PARAM.USER_NAME).getBytes("iso-8859-1"),"UTF-8"), "UTF-8");
tmpPassword = URLDecoder.decode(new String(paramsMap.get(URL_PARAM.PASSWORD).getBytes("iso-8859-1"),"UTF-8"), "UTF-8");

However, to accept unecoded URIs is inherently dangerous. When you get a city with a “space” in the name (like “Bad Hersfeld” or similar) you will get a Vaadin 500 - com.vaadin.server.ServiceException: java.lang.RuntimeException: Invalid location URI received from client.

So best way would be to have the caller encode the URI correctly…

Hope that helps, Frank

https://dev.vaadin.com/ticket/16665

Dear All
I’m new Vaadin developer. I have a problem with Vaadin URI when i try to put special character
!#
in my url it show
"
java.lang.RuntimeException: Invalid location URI received from client
".I didn’t see solution yet.
Do we have solution ?

29301.png
29302.png

Frank Schmitz - Thanks buddy. it worked for me too.