Giter VIP home page Giter VIP logo

Comments (5)

axe312ger avatar axe312ger commented on June 19, 2024

This is related to the internal usage of cheerio to replace the pictures and the configuration I pass: https://github.com/axe312ger/metalsmith-adaptive-images/blob/master/src/index.js#L104-L106

I had to do this to get valid HTML back then in the project I developed this for.

If anybody has a replacement for cheerio which will NOT alter the html code besides the image replacement, I'd be super happy to merge this is. A simple regex is IMHO not reliable enough.

from metalsmith-adaptive-images.

axe312ger avatar axe312ger commented on June 19, 2024

Can you maybe try to remove the xmlMode: true and see if it is working properly for you? That might be a quick fix.

from metalsmith-adaptive-images.

peremenov avatar peremenov commented on June 19, 2024

As described here non-safe solution could be like this:

file.contents = new Buffer($.html({ decodeEntities: false }));

It works fine for me.

from metalsmith-adaptive-images.

axe312ger avatar axe312ger commented on June 19, 2024

Yeah we can't do that :/

var cheerio = require("cheerio")

const $ = cheerio.load('<div>&#x3C;script&#x3E;alert(&#x27;xss&#x27;)&#x3C;/script&#x3E;</div>')

console.log($.html())
// "<div>&lt;script&gt;alert(&apos;xss&apos;)&lt;/script&gt;</div>"

console.log($.html({decodeEntities: false}))
// "<div><script>alert('xss')</script></div>"

from metalsmith-adaptive-images.

peremenov avatar peremenov commented on June 19, 2024

Thank you anyways

from metalsmith-adaptive-images.

Related Issues (14)

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.