From: Michael Paesold <mpaesold@gmx.at>
To: pgsql-jdbc@postgresql.org
Subject: [PATCH] Escaping of SAVEPOINT names
Date: Sun, 05 Nov 2006 22:18:44 +0100
Message-ID: <454E5534.5050007@gmx.at> (raw)
Escaping of savepoint names in org.postgresql.jdbc3.PSQLSavepoint is
incorrect. Backslashes in (double-quoted) savepoint names are doubled
for escaping, but AFAIK, and as my testing shows, savepoint names are
like identifiers, so regular identifier quoting applies to them.
Therefore backslashes should not be doubled, because they have no
special meaning in a double-quoted string.
While at it, don't use the string literal "\"" just to append a single
double-quote character to a string buffer.
Best Regards,
Michael Paesold
Attachments:savepoint-names.patch (text/x-patch, 1.5K) download
diff -crN pgjdbc.c5a36d75e073/org/postgresql/jdbc3/PSQLSavepoint.java pgjdbc/org/postgresql/jdbc3/PSQLSavepoint.java
*** pgjdbc.c5a36d75e073/org/postgresql/jdbc3/PSQLSavepoint.java 2006-11-05 22:08:31.000000000 +0100
--- pgjdbc/org/postgresql/jdbc3/PSQLSavepoint.java 2006-11-05 22:08:31.000000000 +0100
***************
*** 70,87 ****
if (_isNamed)
{
// We need to quote and escape the name in case it
! // contains spaces/quotes/backslashes.
//
StringBuffer sb = new StringBuffer(_name.length() + 2);
! sb.append("\"");
for (int i = 0; i < _name.length(); i++)
{
char c = _name.charAt(i);
! if (c == '\\' || c == '"')
sb.append(c);
sb.append(c);
}
! sb.append("\"");
return sb.toString();
}
--- 70,87 ----
if (_isNamed)
{
// We need to quote and escape the name in case it
! // contains spaces/quotes/etc.
//
StringBuffer sb = new StringBuffer(_name.length() + 2);
! sb.append('"');
for (int i = 0; i < _name.length(); i++)
{
char c = _name.charAt(i);
! if (c == '"')
sb.append(c);
sb.append(c);
}
! sb.append('"');
return sb.toString();
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: mpaesold@gmx.at
Subject: Re: [PATCH] Escaping of SAVEPOINT names
In-Reply-To: <454E5534.5050007@gmx.at>
References: <454E5534.5050007@gmx.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox