[PATCH] Escaping of SAVEPOINT names
[PATCH] Escaping of SAVEPOINT names
От:
Michael Paesold <mpaesold@gmx.at>
Дата:
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
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();
}
Re: [PATCH] Escaping of SAVEPOINT names
От:
Kris Jurka <books@ejurka.com>
Дата:
On Sun, 5 Nov 2006, Michael Paesold wrote: > 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. > Applied to 8.0, 8.1, and HEAD. Kris Jurka