Git Product home page Git Product logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 17, 2024
Also i care about "src" tag
in case of

<DIV STYLE="border-image: url(images/javascript.png) 30 round round;">

i shuld make this check:
PolicyFactory policy = new HtmlPolicyBuilder()
    .allowElements("p")
    .allowElements(new ElementPolicy() {
          public String apply(String elementName, List<String> attrs) {
            StylingPolicy sp = new StylingPolicy();
            sp.allowCSSProperty("color");
            sp.addCssPropertyCheker(new CSSPropertyChecker(){
                boolean includeThisProperty(String propertyName, String properyValue){
                    CSSPropertyValue prop = new  CSSPropertyValue(properyValue);
                     if(prop.isURLResource()){
                        CSSPropertyURL urlProp = new CSSPropertyURL(prop);
                        if(!urlProp.getDomain().equals(MY_DOMAIN)){ 
                           // css resource from third party domain
                           return false;// dissalow
                        } else {
                           return true;
                        }
                     }
                    if (prop.isExpression()){
                         // dissalow like: width: expression(alert('XSS'));
                         return false;
                    }
                    return true;
                }
            }, List.Of("border-image"));
            sp.applyTo(attrs);
          return elementName;
          }
     },TagsSet.ALLOWED)
    .build();
String safeHTML = policy.sanitize(untrustedHTML);

to prevent both "expression" and resource in css url from 3-party domain/

Original comment by [email protected] on 19 Jun 2013 at 2:23

from java-html-sanitizer.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 17, 2024
and dont forget that some css properties can have multiple values

Original comment by [email protected] on 19 Jun 2013 at 2:25

from java-html-sanitizer.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 17, 2024
Also what about < style > tag? Shuld this allow styles from users? In case of 
WYSIWYG there are some styles, that should be allowed. In general there must be 
element style perser.

Original comment by [email protected] on 19 Jun 2013 at 2:56

from java-html-sanitizer.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 17, 2024
Please ask questions on the mailing list, not in the issue list.
https://groups.google.com/forum/?fromgroups#!forum/owasp-java-html-sanitizer-sup
port

Original comment by [email protected] on 19 Jun 2013 at 10:14

  • Changed state: Invalid

from java-html-sanitizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.