You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Gagandeep singh <ga...@gmail.com> on 2010/08/20 15:47:41 UTC

Issue 1966043: Adding the html tag context for the ProxyUri resource

Reviewers: dev@shindig.apache.org, dev-remailer@shindig.apache.org

Description:
<http://codereview.appspot.com/2003041/>

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.


Please review this at http://codereview.appspot.com/1966043/

Affected files:

M
 java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/ProxyingVisitorTest.java
A
 java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/RewriterUtilsTest.java
M
 java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/DefaultProxyUriManagerTest.java
M
 java/gadgets/src/test/java/org/apache/shindig/gadgets/uri/PassthruManager.java
M
 java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/AccelHandler.java
M
 java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/DefaultProxyUriManager.java
M
 java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/UriCommon.java
M
 java/gadgets/src/main/java/org/apache/shindig/gadgets/uri/ProxyUriManager.java
M
 java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java
M
 java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/ProxyingVisitor.java
M
 java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/RewriterUtils.java

Thanks
Gagan