Re: Escape handling in COPY, strings, psql - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Escape handling in COPY, strings, psql
Date
Msg-id 200505301412.j4UECJ207458@candle.pha.pa.us
Whole thread Raw
In response to Re: Escape handling in COPY, strings, psql  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Responses Re: Escape handling in COPY, strings, psql  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
List pgsql-hackers
Christopher Kings-Lynne wrote:
> > I think we can tell people in 8.1 that they should modify their
> > applications to only use '', and that \' might be a security problem in
> > the future.  If we get to that then using ESC or not only affects input
> > of values and literal backslashes being entered, and my guess is that
> > 90% of the backslash entries that want escaping are literal in the
> > application and not supplied by program variables.  In fact, if we
> > disable backslash by default then strings coming in only have to deal
> > with single quotes (like other databases) and the system is more secure
> > because there is no special backslash handling by default.
> 
> I can tell you right now this will be a problem :)  There are loads of 
> PHP ppl who use addslashes() instead of pg_escape_string() to escape data.

I read the PHP addslashes() manual page:
http://us3.php.net/addslashes

First, I see what people mean about PHP having most of the complex
content in comments, rather than in the actual manual text, and this
tendency is certainly something we want to avoid --- you end up having
to digest all the comments to find the details that should be in the
manual already.

On to the case at hand, the comments mention that addslashes() isn't
safe for all databases, and in fact isn't the prefered method.  I do
think it could be a problem we have to have people avoid.  One idea for
8.1 is to throw a warning if \' appears in a string, thereby helping
people find the places they are using the incorrect non-standard
escaping.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Michael Glaesemann
Date:
Subject: Interval->day proposal
Next
From: Christopher Kings-Lynne
Date:
Subject: Re: Escape handling in COPY, strings, psql