Skip to content

Comments at the parser boundary

 1 min XML comments were becoming empty RPC models; configuring the parser removed them before either decoder saw them.
Published

Jun 24, 2012

An XML comment in an rpclib request could become an empty model. The decoder walked child nodes as though each represented protocol data. Comments were nodes too.

The repair configured the tree at the point it was created:

parser = etree.XMLParser(remove_comments=True)

Both parsing paths needed it. Generic XML used etree.fromstring; SOAP used etree.XMLID. Each also had a fallback that retried with a different string encoding. Passing the parser only to the ordinary path would leave the same defect reachable through the fallback, so the patch supplied it there too.

This was a protocol decision, not a statement that XML comments never matter. The RPC model did not assign them a data meaning. Once that was settled, excluding them during parsing was simpler than making every model decoder recognize and skip them independently.

The change merged. It added no new model type and no per-field exception. It made the decoder’s input match the assumption its element walk already depended on.