Re: Escaping metacharacters

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Escaping metacharacters
Дата
Msg-id 87y8lgsokr.fsf@stark.xeocode.com
обсуждение исходный текст
Ответ на Escaping metacharacters  (DarkSamurai <julio@invlaid.linux.net>)
Список pgsql-hackers
DarkSamurai <julio@invlaid.linux.net> writes:

> And suppose I use this :
> 
> > $cat = $GET["category"];
> > $query = " SELECT Id, Title, Abstract FROM News " . "Where Category=" . $cat;

From a security point of view you're even better off using something like

$dbh->query("SELECT id, title, abstract FROM news WHERE category = ?", $cat);

Or whatever the equivalent syntax is in your driver. Avoiding mixing
user-provided data with the code entirely. The driver may still have to do the
mixing but it's probably better at it than you are. And in newer versions of
Postgres it doesn't even have to do it at all, and can ship the data to the
server separately.

-- 
greg



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Toward better documentation
Следующее
От: Bruce Momjian
Дата:
Сообщение: CVS compile failure