Re: [studs-user] Text field specialchars
Status: Beta
Brought to you by:
mojavelinux
|
From: Juan C. R. A. <jc...@um...> - 2006-12-14 09:37:29
|
Juan Carlos Rey Anaya wrote:
> Hello again...
> I have a form in which a field represents html code written by the user.
> I have observed the text value that gets inserted in the DB is escaped.
Well, One more time I have lost inside code and couldn't detect where
the string is escaped :-(
But, I have detected the function that makes the final espace:
WEB_INF/lib/horizon/util/StringUtils::escapeString
As I don't know is this behabiour is configurable, I have recurred to a
home-made remedy :-)
unescaping the final string returned by the ActionForm setter method.
If it were of interest to somebody, here is the function that makes it.
function unescapeString($string, $charsToUnescape = array('\''),
$escapeChar = '\\')
{
foreach ($charsToUnescape as $charToUnescape)
{
$chr_unescaped = str_replace($escapeChar, '', $charToUnescape);
$string = str_replace($escapeChar . $chr_unescaped, $chr_unescaped,
$string);
}
return $string;
}
Cheers
|