Forums / Developer / Entities are always escaped in ezxml

Entities are always escaped in ezxml

Author Message

Gabriel Ambuehl

Saturday 25 March 2006 10:19:33 am

I'm trying to parse XHTML in ezxml and serialize it back to XHTML afterwards:

My code:

        $params= array("ConvertSpecialChars" => false);
        $domTree = $ezxml->domTree( &$data, $params);
        eZDebug::writeNotice($domTree->toString());

The following XHTML fragment is giving me trouble:

<section>
 <p class="xfactbox">aaaaaaaa</p>
  <p>
    a&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aaa
    <br />
    <br />
  </p>
  <p class="xfactbox">
    <span class="xemphasize">aaaaaaaaaa</span>
  </p>
</section>

after serializing it back into a string I get

<?xml version="1.0" encoding="UTF-8"?>
<section>
  <p class="xfactbox">aaaaaaaa</p>
  <p>
    a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aaa
    <br />
    <br />
  </p>
  <p class="xfactbox">
    <span class="xemphasize">aaaaaaaaaa</span>
  </p>
</section>

i.e. the ampersand of the Entity gets escaped itself.

I'm using ezpublish 3.6.6 on php 4.3.10, domxml is installed.

Visit http://triligon.org

Xavier Dutoit

Tuesday 28 March 2006 8:08:01 am

It looks like a bug to me. Any news on that topic ?

X+

http://www.sydesy.com

Gabriel Ambuehl

Tuesday 28 March 2006 11:43:32 am

Yes but it seems to happen during serializing back to text, the dom tree itself is working fine.

Visit http://triligon.org

Xavier Dutoit

Tuesday 28 March 2006 11:06:18 pm

So that's the toString method that doesn't play nicely with & then. Right ?

X+

http://www.sydesy.com

Gabriel Ambuehl

Wednesday 29 March 2006 12:28:58 am

I'd say so.

I got around it with some more hacking of my own (which breaks the use of &amp; in XHTML documents but that doesn't really matter much to me as & should work, too).

Visit http://triligon.org

Kirill Subbotin

Friday 31 March 2006 2:20:51 am

hm... probably toString function need to have some parameter like convertSpecialChars as well... Will this solve a problem?

Gabriel Ambuehl

Friday 31 March 2006 3:35:04 am

It might solve the problem (it's mostly what I tacked on it, but it's not entirely clean I think).

Another issue with ezxml is that it silently discards of special chars (like German umlauts, Euro sign etc)

Visit http://triligon.org

Xavier Dutoit

Friday 31 March 2006 4:41:55 am

I'm not sure this bug is related.

http://ez.no/bugs/view/8068

http://www.sydesy.com

Gabriel Ambuehl

Friday 31 March 2006 5:35:06 am

It's likely somehow related.

It's essentially what I saw with my   examples.

Visit http://triligon.org

Valentin Doroschuk

Tuesday 11 April 2006 5:54:29 am

- Added convertSpecialChars parameter into toString().

Xavier Dutoit

Wednesday 12 April 2006 1:47:20 pm

Hi,

It that on pubsvn ? What version ?

X+

http://www.sydesy.com

Kirill Subbotin

Thursday 13 April 2006 12:35:23 am

stable/3.7 rev. 15624, trunk rev. 15625