Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

issues with XML entities #65

Closed
lsmith77 opened this Issue · 11 comments

3 participants

Lukas Kahwe Smith Christian Stocker Reto Ryter
Lukas Kahwe Smith
Owner
Warning: DOMDocument::loadXML(): Entity 'nbsp' not defined in Entity, line: 3 in /vagrant/symfony/vendor/jackalope/jackalope-doctrine-dbal/src/Jackalope/Transport/DoctrineDBAL/Client.php line 836
Lukas Kahwe Smith
Owner

@dbu: what do you think we need to do here? not quite sure how this can happen, given that we use DOM to generate the XML.

@rryter: can you give us more details on the situation when this happened?

Christian Stocker
Owner

& nbsp ; is not a standard XML entity, it needs a DTD. Does that come from some kind of WYSIWYG editor? You should convert those to numeric entities or proper UTF-8 before (including the proper DTD I would try to avoid)

Not sure anymore, but http://php.net/manual/en/function.html-entity-decode.php should help

Lukas Kahwe Smith
Owner

yeah .. it comes from Hallo.js

Christian Stocker
Owner

We need to clean such things before saving

Lukas Kahwe Smith
Owner

so you propose we apply this conversion inside the Doctrine DBAL Client?

Christian Stocker
Owner

Actually, it should be cleaned before, but Doctrine DBAL should maybe reject that. You never really can know, what kind of encoded stuff comes in.

Or should we just CDATA the output in the XML? Why are we storing that as XML anyway? What happens if my text is "hello"? Do we already encode that properly?

And do other transports not have the same problem?

Lukas Kahwe Smith
Owner

i was wondering too why we dont just store it as CDATA

Christian Stocker
Owner

I guess, we just have to change
https://github.com/jackalope/jackalope-doctrine-dbal/blob/master/src/Jackalope/Transport/DoctrineDBAL/Client.php#L785

with createTextNode()

From: http://php.net/manual/en/domdocument.createelement.php

"The value will not be escaped. Use DOMDocument::createTextNode() to create a text node with escaping support."

So something like

   $element =   $propertyNode->appendChild($dom->createElement('sv:value'));
   $element->appendChild($dom->createTextNode($value));

Lukas Kahwe Smith
Owner

@rryter can you test if that fixes the issue for you?

Reto Ryter

Yes that fixes the problem!

Lukas Kahwe Smith lsmith77 closed this in 44f6998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.