You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by Parth-Brahmbhatt <gi...@git.apache.org> on 2014/08/26 08:49:56 UTC
[GitHub] incubator-storm pull request: STORM-439: Replace purl.js with jque...
GitHub user Parth-Brahmbhatt opened a pull request:
https://github.com/apache/incubator-storm/pull/242
STORM-439: Replace purl.js with jquery url plugin to support special cha...
...racters in topology names.
BugFix: Remove double decoding from the ui server, currently the decoding happens as part of clout.core.clj and ui.core.clj. Removed the decoding from ui.core.clj.
Encode all url components on server side. Added the encodedId as response param to ensure the url from client side uses encoded component but the user still sees unencoded value.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/Parth-Brahmbhatt/incubator-storm STORM-439
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-storm/pull/242.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #242
----
commit c0eec64c74a97ff8a1ba28488a5c2775f4f81bfd
Author: Parth Brahmbhatt <br...@gmail.com>
Date: 2014-08-26T04:12:50Z
STORM-439: Replace purl.js with jquery url plugin to support special characters in topology names.
BugFix: Remove double decoding from the ui server, currently the decoding happens as part of clout.core.clj and ui.core.clj. Removed the decoding from ui.core.clj.
Encode all url components on server side. Added the encodedId as response param to ensure the url from client side uses encoded component but the user still sees unencoded value.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-storm pull request: STORM-439: Replace purl.js with jque...
Posted by revans2 <gi...@git.apache.org>.
Github user revans2 commented on the pull request:
https://github.com/apache/incubator-storm/pull/242#issuecomment-53427732
OK so mustache will do HTML escaping with the ```{{var}}``` like syntax, but it will not do URL encoding. So we have added in URL encoded ids to the result of the REST APIs to allow us to not bother with doing the URL encoding in the browser. That seems OK I guess. But why are we not url decoding the url parameters in the REST API any more? Is it because the ring framework already decodes them for us? And I am really confused why in the visualization-data function we need to double url encode the ids in the link? From the look of it, it is because we take those parameters and place them in a new URL for the rest call. I would much rather have the browser encode them again when making them a part of the URL. encodeURIComponent should be what we want and is a standard part of javascript.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-storm pull request: STORM-439: Replace purl.js with jque...
Posted by revans2 <gi...@git.apache.org>.
Github user revans2 commented on the pull request:
https://github.com/apache/incubator-storm/pull/242#issuecomment-53428003
Oh and if we don't need/use purl any more we should remove it and the license section for it.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-storm pull request: STORM-439: Replace purl.js with jque...
Posted by revans2 <gi...@git.apache.org>.
Github user revans2 commented on a diff in the pull request:
https://github.com/apache/incubator-storm/pull/242#discussion_r16714479
--- Diff: storm-core/src/clj/backtype/storm/ui/core.clj ---
@@ -424,7 +424,7 @@
(if bolt-summs
(mapfn bolt-summs)
(mapfn spout-summs)))
- :link (url-format "/component.html?id=%s&topology_id=%s" id storm-id)
+ :link (url-format "/component.html?id=%s&topology_id=%s" (url-encode id) (url-encode storm-id))
--- End diff --
Why do we need to double encode the id and storm-id? url-format already encodes them once.
```
(defn url-format [fmt & args]
(String/format fmt
(to-array (map #(url-encode (str %)) args))))
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-storm pull request: STORM-439: Replace purl.js with jque...
Posted by Parth-Brahmbhatt <gi...@git.apache.org>.
Github user Parth-Brahmbhatt commented on the pull request:
https://github.com/apache/incubator-storm/pull/242#issuecomment-53454343
Our mustache templates have anchor tags where we just do the following
<a href="/topology.html?id={{id}}">{{name}}</a>
As you already mentioned mustache does the escaping but not encoding. So the above results in unencoded url which results in the bug that we are trying to fix. I have tried reading through mustache docs and googling around to see if there is any way to invoke javascript functions like encodeURIComponent as part of mustache template and I haven't had much luck. The only suggestion was to send lambda constructs as response from server side which is no different then just sending encoded components. There are 3 other alternatives that I could think of:
1) Encode and server side, which is what we are doing right now.
2) Process the json on browser side before rendering using mustache. Pretty much the same thing as above but the client will have to loop through json response twice once to encode and once to render using mustache.
3) Use a more powerful library than mustache or replace all anchor tags with some div's with onclick being handled by jquery.
The easiest of 3 was the 1st option so I went with it. That said, I am not sure what are the general best practices so I don't mind changing it to option 2 or 3 or any other idea that someone else can propose.
The URL decoding happens as part of https://github.com/weavejester/clout/blob/master/src/clout/core.clj#L96
So the decoding on our side results in a bug.
test%5Ftest -> browser sends encoded test%255Ftest -> clout decodes to test%5Ftest -> our code decodes again and tries to look for test_test topology which is not alive.
I can remove the purl.js but I am not sure which library is actually better so if anyone has any comparison points please let me know. I am planning to fix the purl.js bug so if the change request gets approved we can always revert back to it.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] incubator-storm pull request: STORM-439: Replace purl.js with jque...
Posted by Parth-Brahmbhatt <gi...@git.apache.org>.
Github user Parth-Brahmbhatt commented on a diff in the pull request:
https://github.com/apache/incubator-storm/pull/242#discussion_r16726994
--- Diff: storm-core/src/clj/backtype/storm/ui/core.clj ---
@@ -424,7 +424,7 @@
(if bolt-summs
(mapfn bolt-summs)
(mapfn spout-summs)))
- :link (url-format "/component.html?id=%s&topology_id=%s" id storm-id)
+ :link (url-format "/component.html?id=%s&topology_id=%s" (url-encode id) (url-encode storm-id))
--- End diff --
I missed this , I just blindly went through all the urls and encoded the components. Not sure why in my testing I was not able to catch this though.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---