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

Already on GitHub? Sign in to your account

issues with XML entities #65

Closed
lsmith77 opened this Issue Oct 4, 2012 · 11 comments

Comments

Projects
None yet
3 participants
Owner

lsmith77 commented Oct 4, 2012

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
Owner

lsmith77 commented Oct 4, 2012

@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?

Owner

chregu commented Oct 4, 2012

& 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

Owner

lsmith77 commented Oct 4, 2012

yeah .. it comes from Hallo.js

Owner

chregu commented Oct 4, 2012

We need to clean such things before saving

Owner

lsmith77 commented Oct 4, 2012

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

Owner

chregu commented Oct 4, 2012

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?

Owner

lsmith77 commented Oct 4, 2012

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

Owner

chregu commented Oct 4, 2012

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));

Owner

lsmith77 commented Oct 4, 2012

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

rryter commented Oct 4, 2012

Yes that fixes the problem!

@lsmith77 lsmith77 closed this in 44f6998 Oct 4, 2012

lsmith77 added a commit that referenced this issue Oct 4, 2012

Merge pull request #66 from jackalope/entity_fix
fix issue with entity encoding by making the value a CDATA (fixes #65)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment