org.apache.shindig.gadgets.parse.caja
Class CajaCssSanitizer

java.lang.Object
  extended by org.apache.shindig.gadgets.parse.caja.CajaCssSanitizer

public class CajaCssSanitizer
extends Object

Sanitize a CSS tree using Caja. Strip properties and functions that represent ways to execute script. Specifically - Use Caja's CSS property whitelist - Use Caja's CSS function whitelist - Force @import through the proxy and require sanitization. If they cant be parsed, remove them - Force @url references to have the HTTP/HTTPS protocol


Constructor Summary
CajaCssSanitizer(CajaCssParser parser)
           
 
Method Summary
 void sanitize(com.google.caja.parser.css.CssTree css, Uri linkContext, GadgetContext gadgetContext, ProxyUriManager importRewriter, ProxyUriManager imageRewriter)
          Sanitize the given CSS tree in-place by removing all non-whitelisted function calls
 void sanitize(Element styleElem, Uri linkContext, GadgetContext gadgetContext, ProxyUriManager importRewriter, ProxyUriManager imageRewriter)
          Sanitize the CSS content of a style tag.
 String sanitize(String content, Uri linkContext, GadgetContext gadgetContext, ProxyUriManager importRewriter, ProxyUriManager imageRewriter)
          Sanitize the CSS content of a style tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CajaCssSanitizer

@Inject
public CajaCssSanitizer(CajaCssParser parser)
Method Detail

sanitize

public String sanitize(String content,
                       Uri linkContext,
                       GadgetContext gadgetContext,
                       ProxyUriManager importRewriter,
                       ProxyUriManager imageRewriter)
Sanitize the CSS content of a style tag.

Parameters:
content - to sanitize
linkContext - url of containing content
gadgetContext - The gadget context.
importRewriter - to rewrite @imports to sanitizing proxy
imageRewriter - to rewrite images to sanitizing proxy
Returns:
Sanitized css.

sanitize

public void sanitize(Element styleElem,
                     Uri linkContext,
                     GadgetContext gadgetContext,
                     ProxyUriManager importRewriter,
                     ProxyUriManager imageRewriter)
Sanitize the CSS content of a style tag.

Parameters:
styleElem - to sanitize
linkContext - url of containing content
gadgetContext - The gadget context.
importRewriter - to rewrite @imports to sanitizing proxy
imageRewriter - to rewrite images to sanitizing proxy

sanitize

public void sanitize(com.google.caja.parser.css.CssTree css,
                     Uri linkContext,
                     GadgetContext gadgetContext,
                     ProxyUriManager importRewriter,
                     ProxyUriManager imageRewriter)
Sanitize the given CSS tree in-place by removing all non-whitelisted function calls

Parameters:
css - DOM root
linkContext - url of containing content
gadgetContext - The gadget context.
importRewriter - to rewrite links to sanitizing proxy
imageRewriter - to rewrite links to the sanitizing proxy


Copyright © 2007-2012. All Rights Reserved.