djb,
i just want to summarize before we go:
- you are having some "random" html code in order confirmation emails.
- these emails are html emails.
- some item descriptions contain single quotes and double quotes.
- we think that the email problem is related to these quotes in the item descriptions.
the only reason why i reiterate this information, is that i'm still not 100% that is your problem it is entirely possible that the quotes are your problem and you are more sure than i am. i would hate to address something that is not, in fact, the source of your issue... and really it looks like the field $this->products_ordered_attributes is actually the problem field. but lets give it a whirl!
i would replace the following:
$this->products_ordered_html .=
'<tr>' .
'<td class="product-details" align="right" valign="top" width="30">' . $this->products[$i]['qty'] . ' x</td>' .
'<td class="product-details" valign="top">' . $this->products[$i]['name'] . ($this->products[$i]['model'] != '' ? ' (' . $this->products[$i]['model'] . ') ' : '') .
'<nobr><small><em> '. $this->products_ordered_attributes .'</em></small></nobr></td>' .
with
$this->products_ordered_html = htmlspecialcharacters($this->products_ordered_html) .
'<tr>' .
'<td class="product-details" align="right" valign="top" width="30">' . $this->products[$i]['qty'] . ' x</td>' .
'<td class="product-details" valign="top">' . $this->products[$i]['name'] . ($this->products[$i]['model'] != '' ? ' (' . $this->products[$i]['model'] . ') ' : '') .
'<nobr><small><em> '. $this->products_ordered_attributes .'</em></small></nobr></td>' .
you can read about the php function here:
http://php.net/manual/en/function.htmlspecialchars.php
the key is executing that function at the right place.
i hope that helps! good luck!