Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id E378F9FA4A0 for ; Sun, 5 Nov 2006 17:18:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 79451-02 for ; Sun, 5 Nov 2006 17:18:48 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 6ADDF9F976E for ; Sun, 5 Nov 2006 17:18:47 -0400 (AST) Received: (qmail invoked by alias); 05 Nov 2006 21:18:45 -0000 Received: from 85-125-151-239.dynamic.xdsl-line.inode.at (EHLO [192.168.1.15]) [85.125.151.239] by mail.gmx.net (mp021) with SMTP; 05 Nov 2006 22:18:45 +0100 X-Authenticated: #1946847 Message-ID: <454E5534.5050007@gmx.at> Date: Sun, 05 Nov 2006 22:18:44 +0100 From: Michael Paesold User-Agent: Thunderbird 1.5.0.7 (X11/20060915) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: [PATCH] Escaping of SAVEPOINT names Content-Type: multipart/mixed; boundary="------------060804060600080007000907" X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/27 X-Sequence-Number: 16069 This is a multi-part message in MIME format. --------------060804060600080007000907 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------060804060600080007000907 Content-Type: text/x-patch; name="savepoint-names.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="savepoint-names.patch" 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(); } --------------060804060600080007000907--