JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix stuff after </html
authorJason Woofenden <jason@jasonwoof.com>
Thu, 24 Dec 2015 01:47:44 +0000 (20:47 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Thu, 24 Dec 2015 01:47:44 +0000 (20:47 -0500)
parse-html.coffee

index 5dc05a9..0e79a1d 100644 (file)
@@ -520,6 +520,20 @@ svg_attribute_fixes = {
        ychannelselector: 'yChannelSelector'
        zoomandpan: 'zoomAndPan'
 }
+foreign_attr_fixes = {
+       'xlink:actuate': 'xlink actuate'
+       'xlink:arcrole': 'xlink arcrole'
+       'xlink:href': 'xlink href'
+       'xlink:role': 'xlink role'
+       'xlink:show': 'xlink show'
+       'xlink:title': 'xlink title'
+       'xlink:type': 'xlink type'
+       'xml:base': 'xml base'
+       'xml:lang': 'xml lang'
+       'xml:space': 'xml space'
+       'xmlns': 'xmlns'
+       'xmlns:xlink': 'xmlns xlink'
+}
 adjust_mathml_attributes = (t) ->
        for a in t.attrs_a
                if a[0] is 'definitionurl'
@@ -532,6 +546,9 @@ adjust_svg_attributes = (t) ->
        return
 adjust_foreign_attributes = (t) ->
        # fixfull
+       for a in t.attrs_a
+               if foreign_attr_fixes[a[0]]?
+                       a[0] = foreign_attr_fixes[a[0]]
        return
 
 # decode_named_char_ref()
@@ -2718,7 +2735,9 @@ parse_html = (args) ->
                        ins_mode_in_body t
                        return
                if t.type is TYPE_END_TAG and t.name is 'html'
-                       # fixfull fragment case
+                       if flag_fragment_parsing
+                               parse_error()
+                               return
                        ins_mode = ins_mode_after_after_body
                        return
                if t.type is TYPE_EOF
@@ -2812,6 +2831,7 @@ parse_html = (args) ->
                # Anything else
                parse_error()
                ins_mode = ins_mode_in_body
+               process_token t
                return
 
        # 8.2.5.4.23 http://www.w3.org/TR/html5/syntax.html#the-after-after-frameset-insertion-mode
@@ -2852,10 +2872,11 @@ parse_html = (args) ->
                        adjust_svg_attributes t
                adjust_foreign_attributes t
                insert_foreign_element t, acn.namespace
-               if t.flag 'self-closing'
+               if t.flag 'self-closing' # FIXME CONTINUE this isn't getting set
                        if t.name is 'script'
                                t.acknowledge_self_closing()
                                in_foreign_content_end_script()
+                               # fixfull
                        else
                                open_els.shift()
                                t.acknowledge_self_closing()