Re: QF/DataObject mangling input chars
| From: | Ken Restivo | Date: | Fri, 20 May 2005 07:38:46 +0000 |
| Subject: | Re: QF/DataObject mangling input chars | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19296@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thu, May 19, 2005 at 10:02:52PM -0700, Justin Patrin wrote:
> On 5/18/05, Ken Restivo <ken@restivo.org> wrote:
> > I'm really confused by a strange bit of behaviour from QF when used with DataObject.
> >
> > I'm trying to save a text field that has formatting in it: mostly carriage returns
> > and tabs and quotations and some html special chars.
> >
> > As far as I can tell, the \n\r's are passed as actual NL/CR characters in the $vars
> > argument to the QuickForm::process() method. But, then when I actually assign the vars to the
> > DataObject, somehow the NL/CR get turned into actual literal '\', 'n',
> > '\', 'r' characters: 4 chars instead of 2. I have no idea why DataObject is
> > doing that, but it's making me crazy. The stuff then gets saved to the database that way:
> > utterly useless.
> >
> > Somewhere, probably inside DataObject, some magic is happening, and it's Bad magic.
> > What's going on here?
> >
>
> Ummm....no, DataObject does not normally do this. I'm using
> DB_DataObject (with FormBuilder) to enter all sorts of data, often
> including newlines. You should probably check your magic_quotes
> settings.
>
> What DB are you using? Perhaps DB's quoting method is incorrect for
> the DB you're using?
>
I think I've found the problem. I was over-quoting at process() time, and not doing enough
translation at display time. Looks like DataObject quotes slashes already, by itself.
To display the CR/LF's, I'm using nl2br(htmlspecialchars($value)) on frozen data, and not
doing any translation at all on editable data that goes into textboxes, and this is working well so
far.
- -ken
- --
- ---------------
The world's most affordable web hosting.
http://www.nearlyfreespeech.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCjZQGe8HF+6xeOIcRAv0pAJ9j//jUODK2rTD9lULRXkaO7tu/zgCgtM4T
0Ek4pCX4dC6tPguEPH1Afr8=
=gQXU
-----END PGP SIGNATURE-----