Giter Club home page Giter Club logo

Comments (7)

isaacs avatar isaacs commented on August 15, 2024

Ah, <script>, xml's old nemesis. You strike again.

This is why javascript in XHTML needs to be wrapped in <![CDATA[ to be valid. (Which was a stupid awful pattern, imo.)

Yeah, probably <style> should behave the same way.

from sax-js.

tmpvar avatar tmpvar commented on August 15, 2024

pull request including a test, added

from sax-js.

isaacs avatar isaacs commented on August 15, 2024

The tricky thing about this is something like:

<div>
<script>alert("</script>")</script>

I'm certainly not interested in implementing a full JavaScript syntax parser.

Would it be an acceptable constraint to say that </script> in a string will cause it to end the script block? After all, early browser engines worked this way, right?

from sax-js.

isaacs avatar isaacs commented on August 15, 2024

Actually, it seems like any </ is not really allowed by the html spec, so let's start with that.

from sax-js.

vvo avatar vvo commented on August 15, 2024

A lot of websites are doing this:

<script>$('body').html('<div>hello</div>')</script>

And sax-js fails on this.

You give ..

<div>
<script>alert("</script>")</script>

.. as an example for not directly search for </script> to close a <script>.

But this example already fails on browsers which can't interpret it.
This is why most <script> inside <script> are splitted ('<scr'+'ipt').

We are planning on directly search for </script> and be able to handle cases like </div>, what do you think.

from sax-js.

isaacs avatar isaacs commented on August 15, 2024

@vvo sure, patch welcome.

from sax-js.

abarre avatar abarre commented on August 15, 2024

@isaacs, @vvo, the pull request fixing the </script> detection is attached to the issue #80.

from sax-js.

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.