I've just run into a pathological case with HTML parsing. I've always thought that a \[code\]<script>\[/code\] tag would run until the first closing \[code\]</script>\[/code\] tag. But it turns out this is not always the case.This is valid:\[code\]<script><!--alert('<script></script>');--></script>\[/code\]And even this is valid:\[code\]<script><!--alert('<script></script>');</script>\[/code\]But this is not:\[code\]<script><!--alert('</script>');--></script>\[/code\]And neither is this:\[code\]<script>alert('<script></script>');</script>\[/code\]This behavior is consistent in Firefox and Chrome. So, as hard as it is to believe, browsers seem to accept an open+close script tag inside an html comment inside a script tag. So the question is how do browser really parse script tags?This matters because the HTML parsing library I'm using, Nokogiri, assumed the obvious (but incorrect) until-the-first-closing-tag rule and did not handle this edge case. I imagine most other libraries would not handle it either.