html_entity_decode possible bug...?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
paqman
Forum Contributor
Posts: 125
Joined: Sun Nov 14, 2004 7:41 pm
Location: Burnaby, BC, Canada

html_entity_decode possible bug...?

Post by paqman »

Hey guys I need some help. I'm storing the content for a CMS in a mysql table, using htmlentities to encode the information before putting it in the table. I grab the data, use html_entity_decode to get it back to normal, and output it. When I go to edit the content, using TinyMCE (maybe this is a TinyMCE bug, but I've got to start asking somewhere), the '/' which is escaped by two periods (../ in the table) doesn't get the '..'s removed. If we save it from the TinyMCE page, the '..'s get inserted, and we get more and more as we go. Anyone have any ideas?
User avatar
bala_1225
Forum Commoner
Posts: 29
Joined: Tue Jul 28, 2009 3:20 am
Location: chennai,india

Re: html_entity_decode possible bug...?

Post by bala_1225 »

//if ( isset( $_POST ) )
$postArray = &$_POST ; //From TinyMCE editor value.....

foreach ( $postArray as $sForm => $value )
{
if ( get_magic_quotes_gpc() )
$postedValue = stripslashes($value) ;
else
$postedValue = $value;

echo "<div id='$sForm''>$postedValue</div>";
}
U can use like this it will help u .....It will remove all the bugs.......
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: html_entity_decode possible bug...?

Post by jackpf »

Hey,

I don't know anything about tinyMCE or whatever...

But I was just wondering, why are you encoding data on insertion, and decoding it on display? That sounds utterly pointless.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: html_entity_decode possible bug...?

Post by Mark Baker »

a / isn't normally escaped by ..
Are you sure that this is escaping, and not a relative directory path?
User avatar
paqman
Forum Contributor
Posts: 125
Joined: Sun Nov 14, 2004 7:41 pm
Location: Burnaby, BC, Canada

Re: html_entity_decode possible bug...?

Post by paqman »

Well it made sense to me to turn the html code from <a href=" into <a href=" to keep the sql query happier, but that doesn't really matter. I think TinyMCE is adding the extra ..'s itself, but thanks for the help anyways
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: html_entity_decode possible bug...?

Post by jackpf »

That makes no sense - why not use mysql_real_escape_string() instead? That's exactly what it's designed for.
Post Reply