JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
handle nulls properly
[peach-html5-editor.git] / parse-html.coffee
index ed0070a..20bc99c 100644 (file)
@@ -3093,7 +3093,7 @@ parse_html = (args) ->
                                tok_state = tok_state_tag_open
                        when "\u0000"
                                parse_error()
-                               return new_text_node "\ufffd"
+                               return new_text_node c
                        when '' # EOF
                                return new_eof_token()
                        else
@@ -4543,6 +4543,7 @@ parse_html = (args) ->
                else
                        val = txt.substr cur, (next_gt - cur)
                        cur = next_gt + 3
+               val = val.replace(new RegExp("\u0000", 'g'), "\ufffd")
                if val.length > 0
                        return new_character_token val # fixfull split
                return null
@@ -4682,7 +4683,6 @@ parse_html = (args) ->
 
        # text pre-processing
        # FIXME http://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream
-       txt = txt.replace(new RegExp("\u0000", 'g'), "\ufffd") # fixfull spec doesn't say this
        txt = txt.replace(new RegExp("\r\n", 'g'), "\n") # fixfull spec doesn't say this
        txt = txt.replace(new RegExp("\r", 'g'), "\n") # fixfull spec doesn't say this