[Bug 23596] New: A </script> inside a comment (<!--</script>-->) should *always* terminate the script element

https://www.w3.org/Bugs/Public/show_bug.cgi?id=23596

            Bug ID: 23596
           Summary: A </script> inside a comment (<!--</script>-->) should
                    *always* terminate the script element
           Product: WHATWG
           Version: unspecified
          Hardware: PC
               URL: http://www.whatwg.org/specs/web-apps/current-work/mult
                    ipage/tokenization.html#tokenization
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P3
         Component: HTML
          Assignee: ian@hixie.ch
          Reporter: xn--mlform-iua@xn--mlform-iua.no
        QA Contact: contributor@whatwg.org
                CC: mike@w3.org, public-html-admin@w3.org,
                    public-html-wg-issue-tracking@w3.org,
                    qbolec@gmail.com, robin@w3.org,
                    xn--mlform-iua@xn--mlform-iua.no
            Blocks: 23587

Borrowing words/pseudo-code from Jakub Łopuszański in bug 23587, the parsing of
comments inside script elements ought to be changed from, today: 

   state INSIDE_COMMENT_INSIDE_SCRIPT:
     if you see "-->" go to state INSIDE_SCRIPT
     otherwise sit here

to this:

   state INSIDE_SCRIPT:
    if you see "<!--" go to state INSIDE_COMMENT_INSIDE_SCRIPT
    if you see "</script>" go to state OUTSIDE
    otherwise sit here

It is seems like today’s behavior is motivated by theoretical purity rather
than any use case. (If there is use case, what is it?) The purity argument
probably goes like this: Since, after all, the parser treats a <!-- --> inside
a script element as a ”real” comment, the “purity” would suffer if a tag
*inside* the comment (read: the </script> tag) would close the element.

Against this theoretical purity one could claim that the purity is already
broken by the fact that, whether the comment has any effect, is affected by
whether there is a <script> start tag inside it or not - something which turns
comments into “conditional” comments whenever they occur inside script
elements:

   (A) This is non-confomring:

        <script><!--</script> (-->)

       And the motivation for why it non-conforming is only to help authors
catch situations where they *think* they have hidden the </script> end tag
inside a comment, but actually havent.


   (B) But if one adds a <script> start tag inside the comment …

        <script><!--<script></script>-->

       the script is suddenly not closed anymore. It would only be closed if
there had been a *second*   </script> tag after the comment. And the
motivatation for this behavior is just hard to understand and does surprise
“real authors” …

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Tuesday, 22 October 2013 18:08:05 UTC