Re: Character Entity References
- From: George Maicovschi <georgemaicovschi@xxxxxxxxx>
- Date: Sun, 30 Mar 2008 10:51:07 -0700 (PDT)
On Mar 30, 7:27 pm, Michael Fesser <neti...@xxxxxx> wrote:
.oO(George Maicovschi)
The problem starting with escaping the input data using htmlentities()
and from my point of view, escaping data before it goes to the DB is a
rather good thing not a bad one.
Escaping yes, but not in this way. Data in a DB should never be stored
in an output-specific or media-dependent encoding, but in a raw format.
Pure data, nothing else. Just think about things like
* output to something else than HTML, for example a PDF or a plain text
newsletter
* a fulltext search
Both tasks will be almost impossible or at least much more complicated
with HTML data in the DB, but pretty easy to do with raw data.
If the data displays right in the output of the script no worries
there, he decoded it with html_decode_entities().
There's nothing to decode, but to _encode_ if - and only if - necessary.
The current encoding is _not_ necessary.
Why do you guys say it's a lousy consultant because he escaped the
input?
Because it's simply wrong and just shows that the consultant obviously
didn't really understand what escapaing is for and where it has to be
used. Currently it's just the wrong method at the wrong place.
Should he have just made the insert with whatever data came to
him? I would like to hear a strong point of view on this matter, since
escaping inputs is in my opinion (as well in many other devs' opinion)
a very good programming practice and a must.
The escaping in this case doesn't prevent anything, but causes new
problems. Proper escaping for data that goes into a DB has to be done
with functions like mysql_real_escape_string() or prepared statements,
not with an HTML output(!) function.
Micha
You're kinda right here, I jumped to conclusions. But if you use it
only for outputing to HTML then maybe htmlentities is a good way to
go....I use it combined with others techniques in one of my projects
and there haven't been any problems so far.
.
- References:
- Character Entity References
- From: ft310
- Re: Character Entity References
- From: Michael Fesser
- Re: Character Entity References
- From: Jerry Stuckle
- Re: Character Entity References
- From: Michael Fesser
- Re: Character Entity References
- From: George Maicovschi
- Re: Character Entity References
- From: Michael Fesser
- Character Entity References
- Prev by Date: Re: Retrieving many RSS feeds fast?
- Next by Date: Re: How to convert RSS dates to second since epoch?
- Previous by thread: Re: Character Entity References
- Next by thread: Re: Character Entity References
- Index(es):
Relevant Pages
|