Giter Club home page Giter Club logo

Comments (4)

ezyang avatar ezyang commented on July 17, 2024

Browser behavior is to take the last command, so that's what HTML Purifier does too.

Support for double commands should be easy to implement (just stop putting the finished CSS properties in a property-based array, see library/HTMLPurifier/AttrDef/CSS.php but it needs to be gated behind a configuration option.)

from htmlpurifier.

ezyang avatar ezyang commented on July 17, 2024

OK, fixed with new config CSS.AllowDuplicates.

from htmlpurifier.

Daijobou avatar Daijobou commented on July 17, 2024

Thanks! You said for point 1 that HTML Purifier return last command. I can't this confirm. Show my code and result of it:

    $config = HTMLPurifier_Config::createDefault();
    $config->set('Filter.ExtractStyleBlocks', TRUE);
    $purifier = new HTMLPurifier($config);
    $html = $purifier->purify('<style>.test{color:red;color:blue;color:green;}</style>');
    $output_css = $purifier->context->get('StyleBlocks');
    echo $output_css[0];

Result is:

.test {
color:#FF0000
}

#FF0000 is red and the first command.

from htmlpurifier.

ezyang avatar ezyang commented on July 17, 2024

Oh. I know what's going on, and the patch I just pushed isn't going to help you. The problem is that for ExtractStyleBlocks, CSS parsing is done by CSSTidy, which seems to incorrectly deduplicate duplicate styles. There's not much I can do to fix this, since CSSTidy is not my project. I wonder if https://github.com/Cerdic/CSSTidy has fixed this bug; they might be interested in a no-deduplicate mode.

from htmlpurifier.

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.