PHP Deletes Angle Brackets While Parsing HTML: How to Solve

By | February 7, 2009

Today I’ve faced a problem that was quite strange. One of my WordPress installations refused to understand posted angle brackets. This was especially related to tags and the encoded symbols like > < and so on. I started to think what I did before :).

The issue is described at PHP Bugs.  There is no exact solution there that’s why I decided to create this guide.

I’ve found that the issue was found after a recent PHP update using Directadmin custombuild script. I’ve got all recent software, but PHP doesn’t recognize simple symbols. My first thought was that the problem is with XML interpretation, that is especially related to libxml2. I’ve followed Directadmin forums and thought the problem is with libxml2 version.  I’ve tried to update it to version 2.7.3. There was no success as the problem still continued to persist.

#cd /usr/local/directadmin/custombuild
#tar -zxvf libxml2-2.7.3.tar.gz
#cd libxml2-2.7.3
#./configure –with-iconv=/usr/local
#make install

This step itself doesn’t help, but you need to do it in order to fix the entire problem.

The second step you need to make is to build php with libexpat. In order to do this, you will need to perform the following steps:

– install expat-devel by entering  yum install expat-devel.

– add expat support to your PHP build. In order to do this (I assume you’re using custombuild to build PHP), you have to edit /usr/local/directadmin/custombuild/configure/ap2/configure.php5–with-libexpat-dir=/usr is the string you need to end to your current file contents.

expat adding to php

Then you need to update  the PHP version in /usr/local/directadmin/custombuild/versions.txt to 5.2.8 (most current version at the moment). After that you have to build PHP again.

cd /usr/local/directadmin/custombuild
./build php

There is no need to build anything but PHP that’s why I’ve said No to all other proposals (like cURL, Freetype, etc).  As Apache is restarted automatically, you just have to wait while the build process is complete. After that you’re welcome to enjoy your new PHP installation.

One thought on “PHP Deletes Angle Brackets While Parsing HTML: How to Solve

  1. Dave Perry

    Thank you for your post. I had previously downgraded php to make this work. We had to rebuild one of our servers after the RoundCube bug and I needed to make this fix again. I knew there had to be a better fix.

    Thank you again.

Comments are closed.