in reply to HTML::Entities not encoding @ or .

Perl script uses HTML::Entities to encode form input for sql sanitization on fields like fname, lname, email, address1, etc.
I think I've said this before (or at least I should have) but: don't do that. Use placeholders or $dbh->quote that's what they're there for.

update: s/quiote/quote/;

Replies are listed 'Best First'.
Re^2: HTML::Entities not encoding @ or .
by punch_card_don (Curate) on Feb 12, 2008 at 14:30 UTC
    Yes, I took that advice to heart - using placeholders also. Is there some harm also encoding entities will cause?
      Hmm.. if you're also using place holders or quote, it probably won't matter as far as security goes, but it does make it harder to search the database or interact with the DB using anything but your code (I tend to do quite a lot of inspecting using hand-written SQL during development).

      Oh and it'll take more space to encode everything (which may make certain columns unexpectedly too small if someone enters a character you're escaping).

      So it probably won't cause serious harm, it does IMO make it harder to develop and test. I wouldn't do it.

      Yes, if the output from your database ever needs to be anything other than HTML, you'll need to remember to decode it explicitly at that time. The best rule to follow, I've found, is to keep the raw text in the DB, then encode it appropriately at time of output, for the relevant output format in question.