From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | David Wheeler <david(at)wheeler(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: DBD::Pg BYTEA Character Escaping |
Date: | 2001-11-18 05:45:17 |
Message-ID: | 200111180545.fAI5jHx12256@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> If that's true, then any solution escaping non-printable characters is
> overkill, and therefore only the three characters need to be escaped.
> And since it looks like two of them ('\' and "'") are already escaped
> before the non-printable characters are escaped in DBD::Pg, it then it
> seems that this code:
>
> if ($data_type == DBI::SQL_BINARY ||
> $data_type == DBI::SQL_VARBINARY ||
> $data_type == DBI::SQL_LONGVARBINARY) {
> $str=join("", map { isprint($_)?$_:'\\'.sprintf("%03o",ord($_)) }
> split //, $str);
> }
>
> Could be changed to:
>
> s/\0/\\000/g if $data_type == DBI::SQL_BINARY ||
> $data_type == DBI::SQL_VARBINARY ||
> $data_type == DBI::SQL_LONGVARBINARY;
>
> So, the reason I'm posting this query is because I'd like to get
> confirmation, if possible, on this conclusion. Based on the feedback I
> receive, I will submit patches to the DBD::Pg maintainer.
>
> Thanks!
>
> David
>
> PS: If discussion of this issue needs to be moved to the Hackers list,
> I'll be happy to do so. I just thought I'd try here, first.
Yes, you only need to escape NULL for bytea. The above patch looks fine
to me. We can add it to 7.3.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-11-18 05:46:46 | Re: DBD::Pg BYTEA Character Escaping |
Previous Message | David Wheeler | 2001-11-18 04:58:46 | DBD::Pg BYTEA Character Escaping |