GithubHelp home page GithubHelp logo

Comments (2)

iafan avatar iafan commented on June 3, 2024

This is what happens:

  1. We get the editor row as HTML. This HTML contains a <script>....</script> tag that initializes the editor.
  2. We render this HTML in a container using jQuery html() method.
  3. In html() method, jQuery explicitly tests if the passed HTML string contains certain tags, like <script>, <style>, or <link>. If any of these are found, it uses this.empty().append( value ); logic instead of native elem.innerHTML = value;.
  4. jQuery.append() internally calls jQuery.buildFragment() from the given HTML string, and this is where (likely in this code) the resulting string inside embedded JS code gets rewritten (<Error /> is replaced with <Error ></Error>).

The code accidentally worked in the past because the to_js template filter would do double escaping and then pass through a runtime JSON.parse() call. Now that we don't do this kind of escaping, we need to deal with this specific case.

The ultimate fix would be to get rid of this whole HTML editor row snippet and script inside this snippet (by e.g. using a proper React component). meanwhile, a short-term workaround can probably be to make sure the rendered JavaScript strings inside editor row initialization code don't match this regular expression.

I'll PR a change for this fix shortly.

from zing.

julen avatar julen commented on June 3, 2024

Verified on my side, GTM 👍.

from zing.

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.