Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace RegExp HTML parsing #12

Closed
grompe opened this issue Dec 3, 2014 · 1 comment
Closed

Replace RegExp HTML parsing #12

grompe opened this issue Dec 3, 2014 · 1 comment

Comments

@grompe
Copy link
Owner

grompe commented Dec 3, 2014

As mentioned in #11, parsing HTML with RegExp is prone to errors.
Test and use the following:

    <!doctype html>
    <h1 id="result">...</h1>
    <script>
    function parseHTML(str)
    {
      var doc = document.implementation.createHTMLDocument("");
      doc.body.innerHTML = str;
      return doc;
    }

    var doc = parseHTML('<div><script>alert("broken")</'+'script><a href="http://google.com/">link</a></div>');
    var res = doc.querySelectorAll('a[href^="http"]');
    document.getElementById("result").innerHTML = res[0].href;
    </script>
@grompe
Copy link
Owner Author

grompe commented Jun 1, 2018

Done in 1.129.2018.06.

@grompe grompe closed this as completed Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant