opentbs
opentbs copied to clipboard
Random XML rendering (blip/embed)
Hello,
Thanks again for sharing your Library. I'm embedding images on a Word (docx) document and I'm actually facing a strange issue. There are somes XML attributes that are html encoded and some not.
On a file with 23 embed attributes, 2 are wrong like this one
<a:blip r:embed="rId12" cstate="print">
Other are corrects like the Following :
<a:blip r:embed="rId12" cstate="print">
When I checked function that generate this line, the quote symbol is correct
// phpdocx/classes/CreateElement.php:180
protected function generateBLIP($cstate = 'print')
{
$xml = '<' . CreateImage::NAMESPACEWORD1 .
':blip r:embed="rId' . $this->getRId() .
'" cstate="' . $cstate .
'"></' . CreateImage::NAMESPACEWORD1 .
':blip>__GENERATEBLIPFILL__';
$this->_xml = str_replace('__GENERATEBLIPFILL__', $xml, $this->_xml);
}
Did I do something wrong?
Version used: 3.10.1 PHP: 5.5.9 & 7.2.7
I cannot see how OpenTBS could have changed this character. Can you provide a snippet that reproduces the problem ?
I'll try to make a minimal example, but it's a 20 pages document generated by a WordPress database.
It appears that we had a "&" in some textual content that was not escaped. And & is a reserved character in XML. As soon as we escaped it on content, the problem on the attribute disappears.
$string = str_replace('&', '& ', $string);