Zunenonooo / dompdf

Automatically exported from code.google.com/p/dompdf
0 stars 0 forks source link

Invalid attributes in HTML should be ignored and not throw a DOMException #528

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
My bad HTML code (<table 1="" border="1" cellpadding="1">) was causing a 
DOMException to be thrown in the TreeBuilder::insertElement() method as it was 
trying to create a numeric attribute in the XML which is not allowed in XML 
definition.

Ideally it should skip invalid attributes and not throw an error. Is there a 
method that checks the validity of attribute names before it tries to create 
them?

At the moment a quick fix I'm using is to check if it's not numeric:

if(!$el->hasAttribute($attr['name']) && !is_numeric($attr['name'])) { ... }

but there should be something in the DOMPDF api that is implemented for such a 
situation and be a bit more robust than just checking its not numeric :)

Thank you.

Original issue reported on code.google.com by a_re...@live.co.uk on 24 Aug 2012 at 11:36

GoogleCodeExporter commented 8 years ago
Hello, this is a bug in the HTML5 parse we use 
(http://code.google.com/p/html5lib/). I'm happy to see that at least someone 
uses it :)
Could you submit a bug report in there tracker ? I'll fix it in our copy of the 
lib.

Original comment by fabien.menager on 24 Aug 2012 at 12:18

GoogleCodeExporter commented 8 years ago
It was fixed by r501. Can you confirm this ?

Original comment by fabien.menager on 24 Aug 2012 at 12:27

GoogleCodeExporter commented 8 years ago

Original comment by eclecticgeek on 30 May 2013 at 5:16