Giter Club home page Giter Club logo

Comments (6)

acstll avatar acstll commented on June 7, 2024 2

This module is actually using lodash.escape already haha, which does that exactly:

https://lodash.com/docs/#escape
https://github.com/snabbdom/snabbdom-to-html/blob/master/package.json#L29

I'll try and fix this over the weekend. PR's are welcome too :-)

from snabbdom-to-html.

zkochan avatar zkochan commented on June 7, 2024 1

Actually, it is enough to encode just the <>"&. This is how preact does it:

https://github.com/developit/preact-render-to-string/blob/1a04dc098a24dd916db79990d50a3ebb0c7a6976/src/util.js#L21

from snabbdom-to-html.

acstll avatar acstll commented on June 7, 2024

Thanks for pointing this out.

Indeed snabbdom uses document.createTextNode, which I guess does the encoding. See https://github.com/snabbdom/snabbdom/blob/master/src/htmldomapi.ts#L27-L29

What do you think would be the simplest way to do the encoding and apply it to vnode.text? https://github.com/snabbdom/snabbdom-to-html/blob/master/init.js#L33

from snabbdom-to-html.

zkochan avatar zkochan commented on June 7, 2024

I am not aware of built-in Node.js modules that would encode HTML. I searched on npm and seems like the he is the most popular package for encoding/decoding HTML

from snabbdom-to-html.

acstll avatar acstll commented on June 7, 2024

Another hand-made take https://github.com/stasm/innerself/blob/master/sanitize.js

from snabbdom-to-html.

rbelouin avatar rbelouin commented on June 7, 2024

@zkochan, @acstll: Hi! This does not seem to be fixed, so I've tried to address the issue in #38

from snabbdom-to-html.

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.