Giter Site home page Giter Site logo

Comments (2)

elgonzo avatar elgonzo commented on September 21, 2024

Chrome seems to be able to parse HTML like this correctly.

You seem to be mistaken. I find HtmlAgility's parsing behavior in this case to broadly match the parsing behavior of browsers like Chrome and Firefox.

Chrome 118.0.5993.118 behavior is equivalent to what you observed with HtmlAgilityPack. Loading your example HTML into Chrome yields this result:
Ch
Note how the part of the intended Javascript code after the first occurence of </script> is treated as text content for the HTML body, more or less like HAP does (there might or might not be differences in how the browsers and HAP handle the "stray" secondary </script> closing element, but that's not really relevant regarding the point i am making here).

Firefox 118.0.2 behaves in the same manner as Chrome and HtmlAgilityPack:
ff

Also, in case you aren't already aware of it, worth of note in this context are also the restrictions the HTML standard places on the content of script elements: https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements


P.S.: I am just a user and not associated with the HAP project nor its authors/maintainers.

from html-agility-pack.

JonathanMagnan avatar JonathanMagnan commented on September 21, 2024

Hello @shravan2x ,

Let me know if the answer from @elgonzo is good.

I tested it also on Firefox and got the same behavior as him and HAP.

Best Regards,

Jon

from html-agility-pack.

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.