Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random XML rendering (blip/embed) #6

Open
matll42 opened this issue Sep 10, 2018 · 3 comments
Open

Random XML rendering (blip/embed) #6

matll42 opened this issue Sep 10, 2018 · 3 comments

Comments

@matll42
Copy link

matll42 commented Sep 10, 2018

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=&quot;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

@Skrol29
Copy link
Owner

Skrol29 commented Sep 10, 2018

I cannot see how OpenTBS could have changed this character. Can you provide a snippet that reproduces the problem ?

@matll42
Copy link
Author

matll42 commented Sep 12, 2018

I'll try to make a minimal example, but it's a 20 pages document generated by a WordPress database.

@matll42
Copy link
Author

matll42 commented Nov 6, 2018

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('&', '&amp; ', $string);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants