On 17 Nov 2001, David Wheeler wrote:
> The second issue, however, is that it doesn't appear to me that it's
> even necessary that non-printable characters be replaced. Although Alex
> Pilosov says that such an approach is needed:
>
> http://www.geocrawler.com/mail/msg.php3?msg_id=6509224&list=10
I didn't say it was needed :) I just had the easy way out and escaped
everything that might possibly need to be escaped.
> Joe Conway found that there were only three characters ('\', "'", and
> "\0") that needed to be escaped, and it was those three characters that
> Bruce Momjian documented for the forthcoming 7.2 release:
Right.
> http://www.geocrawler.com/mail/msg.php3?msg_id=6547225&list=10
>
> 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;
Yep.
>
> 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.
Go right ahead.
-alex