Skip to content

Fix for parsing broken processing instructions#1

Open
jkoops wants to merge 5 commits intof4b25b7a6ffrom
master
Open

Fix for parsing broken processing instructions#1
jkoops wants to merge 5 commits intof4b25b7a6ffrom
master

Conversation

@jkoops
Copy link
Copy Markdown
Owner

@jkoops jkoops commented Oct 15, 2010

Some HTML contains broken processing instructions, such as this one encountered in the wild: <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />.

The parser crashes on this since it only accepts ?> (or end-of-file) as the end of a processing instruction. This patch fixes it by also allowing > or /> to end a processing instruction.

jkoops and others added 5 commits October 15, 2010 16:14
Some HTML contains broken processing instructions, such as this one
encountered in the wild: `<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />`.

The parser crashes on this since it only accepts `?>` (or end-of-file) as
the end of a processing instruction. This patch fixes it by also
allowing `>` or `/>` to end a processing instruction.
Some HTML contains broken processing instructions, such as this one
encountered in the wild: `<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />`.

The parser crashes on this since it only accepts `?>` (or end-of-file) as
the end of a processing instruction. This patch fixes it by also
allowing `>` or `/>` to end a processing instruction.
When the HTML parser attempts to parse tags that should be
singletons but are not, AND they have content, an exception
occurs:

  1> mochiweb_html:parse("<html><input><input>x</input></input></html>").
  ** exception error: no case clause matching
        	            {[],[{<<"input">>,[],[<<"x">>]},{<<"input">>,[],[]}]}
       in function  mochiweb_html:destack/2
       in call from mochiweb_html:tree/2
       in call from mochiweb_html:parse_tokens/1

This patch provides a fix.
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

Successfully merging this pull request may close these issues.

2 participants