If an HTML character, like '&', is inserted into a customer profile field we're seeing this error when creating an Authorize.net CIM profile:

Warning: SimpleXMLElement::addChild(): unterminated entity reference XXX & XXXX in commerce_simplexml_add_children() (line 953 of ...sites/all/modules/contrib/commerce/commerce.module).

I've created a patch that escapes the $value var when its added to the XML doc.

If the commerce_authnet module should be escaping the data before passing it to the commerce_simplexml_add_children() function I will move my bug report over to there.

Comments

epicflux’s picture

Issue summary: View changes
epicflux’s picture

StatusFileSize
new472 bytes

I've updated this patch to call htmlspecialchars directly with the $double_encode parameter set to FALSE.

Status: Needs review » Needs work

The last submitted patch, 2: unterminated-entity-reference-2314151-2.patch, failed testing.

michfuer’s picture

Status: Needs work » Needs review
StatusFileSize
new459 bytes

Not sure why patch 2 failed the SimpleTest. Here's an alternative method from stack overflow http://stackoverflow.com/questions/17027043/unterminated-entity-referenc..., which should accomplish the same thing.

rszrama’s picture

rszrama’s picture

Status: Needs review » Fixed

I went ahead and committed epicflux's patch. I'm not sure what answer you were looking at, Mike, but your patch changes the XML by adding a value child node to every element. No bueno.

  • rszrama committed 2f91d8e on 7.x-1.x authored by epicflux
    Issue #2314151 by epicflux: Fix an unterminated entity reference error...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.