-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
navigateTo + ViewChangeEvent.parameterList may double URL decode #28
Comments
Forgot to mention: |
Hi, thanks for letting me know! I have created a test case for this bug, but I'm unable to reproduce it in a mocked environment. Can you look at this test please and maybe try to make it fail? https://github.com/mvysny/karibu-dsl/blob/master/karibu-dsl-v8/src/test/kotlin/com/github/vok/karibudsl/NavigatorTest.kt Yet from what you say, it seems that Vaadin is doing something wrong and it is only shown when the request goes through an actual browser... |
Yes I will try your test but in my cases it only breaks when using a bookmarked or manual history or a hard refresh where the URL comes through some other path (maybe even javascript). |
I tried the following as a top level view. Result: (given "http://foo/bar" )
How go to browser bar and hit REFRESH Results: (wrong/inconsistant) For fun keep pressing PUSH ... this simulates doing the URL Encode prior to passing to navigateToView
|
You're right, the outcome looks pretty random to me. I tried to remove the VoK-related code, to see how pure Vaadin would behave. The behavior is even more random. I have the following app:
I am somehow at loss as to what to make of the above. It seems that double slash kills Vaadin reliably, yet |
Also it seems it's impossible to pass double-slash via a parameter: if you pass it unescaped, Vaadin widgetset will fail to be loaded. If you pass it escaped, Tomcat will complain with |
Circling back to the original bug: you're right. It seems that Vaadin does not do escaping at all on |
The workaround seems to be to remove the |
Filed a bug: vaadin/framework#11057 |
Also related: vaadin/framework#11060 |
Interesting wrt @PushStateNavigation --- nievely guessing that is due to the URL being (or not) processed by Tomcat (or jetty in my case) vs being 'data' in the push stream and processed by vaadin (or not). |
Maybe this can be moved to a "Feature Request" by adding support for typed parameters.
As I enhance the above to handle cases like a form refresh ( requires saving previous args), general purpose 'goToEditorForObject()" more becomes boilerplate and eventually pushed downto a common view subtype. Seems like a better aproach is deeper integration into the navigator that supports 'safe typed values' , i.e. a navigation API like inline fun <reified T:Any,reified V:View> navigateTo( arg: T ) {
< hand waving -- details are tricky >
|
If I use parameters that require URL encoding in Navigator.navigateToView(), a subsequecent ViewChangeEvent.parameterList may double -URL decode depending on if this is a direct in-app navigation or if it is the result of browser-side request (refresh, bookmark, manual enter).
Example:
navigateToView( DocstoreTreeView::class.java , item.url )
where item.url is a string in URL format such as https://somewhere/over/the/rainbow
the corresponding enter events parameterList may be either
[ "0" -> "https://somewhere/over/the/rainbow"]
Or
[ "0" -> "https" , "1" -> "somewhere/over/the/rainbow" ]
I tracked this down to largely correct (*) code that encodes on navigate and decodes on enter,
the cause seems to be Vaadin code which in the direct case supplies the ENCODED string "parameters" but in the refresh/manual case supplies the DECODED string. Which then vok decodes again.
In many cases this doesn't matter, in the above case there is 1 bug from the extra decode and 1 bug from vok implementation
#1 might be able to work around if #2 were not an issue. (#2 cannot determine between "/" or "//" being stripped)
Suggest that at minimal the code in parameterList be changed to NOT remove empty parameters, this would allow a workaround of the vaadin issue (not able to determine core cause yet)
The text was updated successfully, but these errors were encountered: