Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(238)

Issue 1966043: Adding the html tag context for the ProxyUri resource (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 5 months ago by gagan.goku
Modified:
15 years, 4 months ago
Reviewers:
Paul Lindner, dev, dev-remailer
CC:
cool-shindig-committers_googlegroups.com, satya3656, anupama.dutta
Base URL:
http://svn.apache.org/repos/asf/shindig/trunk/
Visibility:
Public.

Description

This change: 1) Adds the html tag (called htmlTagContext) for which the resource is being proxied. 2) Propogates html tag context all the way to HttpRequest. 3) Rewrite html pages only if the htmlTagContext is not "script". The motivation of this change is two fold: 1) We get more control and context about the url requested by the browser. 2) This helps us not rewrite pages which have their Content-Type header incorrectly set. For example, we recently ran into javascript pages that set Content-Type incorrectly as "text/html". We end up rewriting the content (enclose it in "<html> .. </html>") and the browser is no longer able to execute the javascript. For example: Original html snippet: <script src="/gadgets/proxy?url=1.js&....> Http Request for resource: GET 1.js HTTP/1.0 .... Http Response: 200 OK Content-Type: text/html var hello = "buffalo"; .... RewriterUtils.isHtml() returns true Final response: 200 OK Content-Type: text/html <html><body>var hello = "buffalo";</body></html> = Browser unhappy :( Hence this change. We can later add more strict control by blacklisting more tags like "img" etc., or we could whitelist only known html tags like "iframe", "link" etc. However, the current need is only to correct javascript resources with incorrect content type headers.

Patch Set 1 #

Patch Set 2 : '2nd_pass' #

Patch Set 3 : svn_up #

Patch Set 4 : svn_up #

Patch Set 5 : reverting_unnecessary_files #

Patch Set 6 : copying_from_1969044 #

Patch Set 7 : svn_up #

Patch Set 8 : 'updating_comment' #

Patch Set 9 : 'updating_comment' #

Patch Set 10 : 'adding_tests' #

Patch Set 11 : 'adding_tests' #

Patch Set 12 : 'adding_more_tests' #

Patch Set 13 : 'adding_more_tests' #

Total comments: 6

Patch Set 14 : svn_up #

Total comments: 8

Patch Set 15 : svn_up #

Patch Set 16 : adding_more_instances_of_html_tag_context #

Patch Set 17 : lint #

Total comments: 2

Patch Set 18 : addressing_anupamas_comment #

Total comments: 6

Patch Set 19 : addressing_anupamas_comments #

Patch Set 20 : svn_up #

Unified diffs Side-by-side diffs Delta from patch set Stats (+170 lines, -28 lines) Patch
M java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java View 18 19 2 chunks +9 lines, -5 lines 0 comments Download
M java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/ProxyingVisitor.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +3 lines, -0 lines 0 comments Download
M java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/RewriterUtils.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 3 chunks +19 lines, -2 lines 0 comments Download
M java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/AccelHandler.java View 16 17 18 19 3 chunks +7 lines, -3 lines 0 comments Download
M java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultProxyUriManager.java View 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +4 lines, -2 lines 0 comments Download
M java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/ProxyUriManager.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 6 chunks +27 lines, -5 lines 0 comments Download
M java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/UriCommon.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +5 lines, -1 line 0 comments Download
M java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ProxyingVisitorTest.java View 10 11 12 13 14 15 16 17 18 19 1 chunk +5 lines, -0 lines 0 comments Download
A java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/RewriterUtilsTest.java View 10 1 chunk +62 lines, -0 lines 0 comments Download
M java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultProxyUriManagerTest.java View 10 11 12 13 14 15 16 17 18 19 2 chunks +26 lines, -9 lines 0 comments Download
M java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/PassthruManager.java View 16 17 18 19 1 chunk +3 lines, -1 line 0 comments Download

Messages

Total messages: 14
satya3656
Nice CL LGTM
15 years, 5 months ago (2010-08-14 11:35:37 UTC) #1
gagan.goku
Thanks :) On Sat, Aug 14, 2010 at 5:05 PM, <satya3656@gmail.com> wrote: > Nice CL ...
15 years, 5 months ago (2010-08-16 05:19:10 UTC) #2
anupama.dutta
http://codereview.appspot.com/1966043/diff/10005/4021 File java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/RewriterUtils.java (right): http://codereview.appspot.com/1966043/diff/10005/4021#newcode54 java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/RewriterUtils.java:54: return htmlTagName == null || !htmlTagName.equals("script"); return "script".equals(htmlTagName); http://codereview.appspot.com/1966043/diff/10005/4021#newcode67 ...
15 years, 5 months ago (2010-08-16 06:56:32 UTC) #3
gagan.goku
http://codereview.appspot.com/1966043/diff/10005/4021 File java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/RewriterUtils.java (right): http://codereview.appspot.com/1966043/diff/10005/4021#newcode54 java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/RewriterUtils.java:54: return htmlTagName == null || !htmlTagName.equals("script"); On 2010/08/16 06:56:32, ...
15 years, 5 months ago (2010-08-16 07:07:13 UTC) #4
anupama.dutta
http://codereview.appspot.com/1966043/diff/26002/27004 File java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultProxyUriManager.java (right): http://codereview.appspot.com/1966043/diff/26002/27004#newcode249 java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultProxyUriManager.java:249: proxied.setHtmlTagContext(uriIn.getQueryParameter(Param.HTML_TAG_CONTEXT.getKey())); Could you check other cases where "new ProxyUri()" ...
15 years, 5 months ago (2010-08-16 09:15:55 UTC) #5
gagan.goku
http://codereview.appspot.com/1966043/diff/26002/27004 File java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultProxyUriManager.java (right): http://codereview.appspot.com/1966043/diff/26002/27004#newcode249 java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultProxyUriManager.java:249: proxied.setHtmlTagContext(uriIn.getQueryParameter(Param.HTML_TAG_CONTEXT.getKey())); On 2010/08/16 09:15:55, anupama.dutta wrote: > Could you ...
15 years, 5 months ago (2010-08-16 18:03:20 UTC) #6
anupama.dutta
http://codereview.appspot.com/1966043/diff/34001/29009 File java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/ProxyUriManager.java (right): http://codereview.appspot.com/1966043/diff/34001/29009#newcode193 java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/ProxyUriManager.java:193: res.add(new ProxyUri(gadget, uri)); If uri had a param for ...
15 years, 5 months ago (2010-08-17 06:29:34 UTC) #7
gagan.goku
http://codereview.appspot.com/1966043/diff/34001/29009 File java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/ProxyUriManager.java (right): http://codereview.appspot.com/1966043/diff/34001/29009#newcode193 java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/ProxyUriManager.java:193: res.add(new ProxyUri(gadget, uri)); On 2010/08/17 06:29:35, anupama.dutta wrote: > ...
15 years, 5 months ago (2010-08-18 10:16:43 UTC) #8
gagan.goku
Synced to head and tested that all shindig tests pass :)
15 years, 5 months ago (2010-08-18 10:21:44 UTC) #9
anupama.dutta
http://codereview.appspot.com/1966043/diff/8/24010 File java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java (right): http://codereview.appspot.com/1966043/diff/8/24010#newcode288 java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java:288: proxiedUri.setHtmlTagContext(attr.getOwnerElement().getNodeName()); Shall we lowercase this for safety here? http://codereview.appspot.com/1966043/diff/8/24010#newcode355 ...
15 years, 5 months ago (2010-08-19 07:27:53 UTC) #10
gagan.goku
http://codereview.appspot.com/1966043/diff/8/24010 File java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java (right): http://codereview.appspot.com/1966043/diff/8/24010#newcode288 java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java:288: proxiedUri.setHtmlTagContext(attr.getOwnerElement().getNodeName()); On 2010/08/19 07:27:53, anupama.dutta wrote: > Shall we ...
15 years, 5 months ago (2010-08-19 14:15:14 UTC) #11
anupama.dutta
LGTM.
15 years, 5 months ago (2010-08-20 09:57:21 UTC) #12
Paul Lindner
lgtm, committing
15 years, 4 months ago (2010-08-27 13:13:22 UTC) #13
gagan.goku
15 years, 4 months ago (2010-08-27 13:14:59 UTC) #14
Thanks Paul :)

On Fri, Aug 27, 2010 at 6:43 PM, <lindner@inuus.com> wrote:

> lgtm, committing
>
> http://codereview.appspot.com/1966043/
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b