Coder Social home page Coder Social logo

Comments (8)

StephanHoyer avatar StephanHoyer commented on June 23, 2024

Hi,

I changed this is for security reasons. Output is now always quoted as mithril also does.

you can avoid the quoting by using

return m('SCRIPT', m.trust('var who = ' + JSON.stringify(ctrl.js));

Didn't test if this works for JSON. May you can and confirm that it's working.

from mithril-node-render.

jsguy avatar jsguy commented on June 23, 2024

Yep, confirmed working, cheers! 👍

from mithril-node-render.

jsguy avatar jsguy commented on June 23, 2024

Ah, wait, no, I was still using 0.1.5.

It's still doing the quotes, even though it's m.trust - it seems as though it always applies the escapeHtml no matter what...

from mithril-node-render.

StephanHoyer avatar StephanHoyer commented on June 23, 2024

Stange

I'll fix that tomorrow. Fell free to open a PR if you want

from mithril-node-render.

jsguy avatar jsguy commented on June 23, 2024

I've created a mithril demo here:

http://codepen.io/jsguy/pen/azGmbw?editors=101

I'm not sure how to best solve this - do we need to override m.trust, so that we know the call is from there?

from mithril-node-render.

jsguy avatar jsguy commented on June 23, 2024

Also, here is a runnable, with the same view to show the issue in node:

http://web-b7843201-9634-4b57-b4ae-2203d5cc5bbd.runnable.com

Hmmm... if that doesn't work, (runnable is sometimes a little "moody"), the code is:

var http = require('http'),
  m = require('mithril'),
  render = require('mithril-node-render');

http.createServer(function (req, res) {
  var result = "", obj = {"hello": "world"};

  result =  render(m("CODE", "var who = " + JSON.stringify(obj)));

  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end(result);
}).listen(80);
console.log('Server listening on port 80');

Output:

<CODE>var who = {&quot;hello&quot;:&quot;world&quot;}</CODE>

from mithril-node-render.

StephanHoyer avatar StephanHoyer commented on June 23, 2024

Just released 0.2.2

I now only escape quotes for attributes. Hope that solves the issue.

from mithril-node-render.

jsguy avatar jsguy commented on June 23, 2024

Works for me, thanks! 👍

from mithril-node-render.

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.