PDA

View Full Version : htmlentities and datamanagers


sheppardzwc
01-11-2011, 09:21 PM
Hi all, ran into a bit of a problem here,

Trying to insert some information I'm getting from IMDb into a post but whenever it has certain characters like an apostrophe it converts it into it's entity counterpart? (') Any idea how to prevent this.. is there a variable I need to pass into the datamanager? Tried html_entity_decode when I set the pagetext in the DM but it doesn't have the "entities" yet so it isn't decoding anything...

Thanks.

(here's a snippet of what's going on)

<?php

foreach ($movie->cast() as $cast) {
$num++;
if ($num <= $castnum) {
$actors = array_merge((!is_array($actors)) ? array() : $actors, array(
$cast['name'] => array(
'role' => $cast['role'],
'photo' => $cast['thumb']
)));
}
}
foreach ($actors as $actor => $other) {
$castformatted .= $actor . ' as ' . $other['role'] . "\r\n";
}
$info = str_replace('{id}', $id, $vbulletin->options['auto_imdb_infoformat']);
$info = str_replace('{title}', $title, $info);
$info = str_replace('{year}', $year, $info);
$info = str_replace('{cast}', $castformatted, $info);
$info = str_replace('{genre}', $genre, $info);
$info = str_replace('{photo}', $photo, $info);
$dm = datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$dm->set_existing(fetch_postinfo($newpost['postid']));
$dm->set('pagetext', $newpost['message'] . "\r\n\r\n" . html_entity_decode($info));

?>

kh99
01-11-2011, 09:35 PM
According to the doc for html_entity_decode (http://us2.php.net/manual/en/function.html-entity-decode.php), by default it doesn't convert single quotes (ENT_COMPAT), so maybe that's the problem? (Although you said "certain characters", so if ' isn't the only one, maybe that's not it).

sheppardzwc
01-12-2011, 02:45 AM
According to the doc for html_entity_decode (http://us2.php.net/manual/en/function.html-entity-decode.php), by default it doesn't convert single quotes (ENT_COMPAT), so maybe that's the problem? (Although you said "certain characters", so if ' isn't the only one, maybe that's not it).
Thanks for your reply. I went ahead and tried ENT_QUOTES obviously (thank you :p) and that still doesn't do anything as the original text I'm giving the post doesn't seem to have the problem. It seems like it's being "entitied" with the post datamanager, or am I just missing something here?

EDIT: found out they were being sanitized somewhere else and I didn't even notice, nevermind :|