shindig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1152394 - in /shindig/trunk/java/gadgets/src: main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java test/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriterTest.java
Date Fri, 29 Jul 2011 23:08:10 GMT
Author: johnh
Date: Fri Jul 29 23:08:09 2011
New Revision: 1152394

URL: http://svn.apache.org/viewvc?rev=1152394&view=rev
Log:
Switch SanitizingGadgetRewriter to a Provider rather than static injection.


Modified:
    shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java
    shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriterTest.java

Modified: shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java?rev=1152394&r1=1152393&r2=1152394&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java
(original)
+++ shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriter.java
Fri Jul 29 23:08:09 2011
@@ -22,6 +22,7 @@ import com.google.common.collect.Immutab
 import com.google.common.collect.ImmutableSet;
 import com.google.inject.BindingAnnotation;
 import com.google.inject.Inject;
+import com.google.inject.Provider;
 
 import org.apache.shindig.common.uri.Uri;
 import org.apache.shindig.gadgets.Gadget;
@@ -97,8 +98,8 @@ public class SanitizingGadgetRewriter ex
   };
 
   @Inject
-  public SanitizingGadgetRewriter(@AllowedTags Set<String> allowedTags,
-      @AllowedAttributes Set<String> allowedAttributes,
+  public SanitizingGadgetRewriter(@AllowedTags Provider<Set<String>> allowedTags,
+      @AllowedAttributes Provider<Set<String>> allowedAttributes,
       ContentRewriterFeature.Factory rewriterFeatureFactory,
       CajaCssSanitizer cssSanitizer,
       ProxyUriManager proxyUriManager) {
@@ -212,23 +213,23 @@ public class SanitizingGadgetRewriter ex
    * Restrict the set of allowed tags and attributes
    */
   static final class BasicElementFilter extends SanitizingWalker {
-    private final Set<String> allowedTags;
-    private final Set<String> allowedAttributes;
+    private final Provider<Set<String>> allowedTags;
+    private final Provider<Set<String>> allowedAttributes;
     
-    private BasicElementFilter(Set<String> allowedTags,
-                               Set<String> allowedAttributes) {
+    private BasicElementFilter(Provider<Set<String>> allowedTags,
+                               Provider<Set<String>> allowedAttributes) {
       this.allowedTags = allowedTags;
       this.allowedAttributes = allowedAttributes;
     }
     
     @Override
     public boolean removeTag(Gadget gadget, Element elem, Uri context) {
-      return !allowedTags.contains(elem.getNodeName().toLowerCase());
+      return !allowedTags.get().contains(elem.getNodeName().toLowerCase());
     }
 
     @Override
     public boolean removeAttr(Gadget gadget, Attr attr, Uri context) {
-      return !allowedAttributes.contains(attr.getName().toLowerCase());
+      return !allowedAttributes.get().contains(attr.getName().toLowerCase());
     }
   }
 

Modified: shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriterTest.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriterTest.java?rev=1152394&r1=1152393&r2=1152394&view=diff
==============================================================================
--- shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriterTest.java
(original)
+++ shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/render/SanitizingGadgetRewriterTest.java
Fri Jul 29 23:08:09 2011
@@ -123,7 +123,7 @@ public class SanitizingGadgetRewriterTes
         new ContentRewriterFeature.Factory(null,
           Providers.of(new ContentRewriterFeature.DefaultConfig(
             ".*", "", "HTTP", "embed,img,script,link,style", false, false, false)));
-    return new SanitizingGadgetRewriter(newTags, attributes, rewriterFeatureFactory,
+    return new SanitizingGadgetRewriter(Providers.of(newTags), Providers.of(attributes),
rewriterFeatureFactory,
         new CajaCssSanitizer(new CajaCssParser()), new PassthruManager("host.com", "/proxy"));
   }
 



Mime
View raw message