summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/dumputils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-08-14 14:19:11 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-08-14 14:19:11 +0000
commit2b5f049f7c6231cce3d79b8949f7aeee3bb4081a (patch)
tree17e5a48c5a7ceb22f5dd3de33ff7339ee3ccbc72 /src/bin/pg_dump/dumputils.c
parent8e97f45f88aeb2ac83cde4910a9216d970a4c0f7 (diff)
Handle double-quotes correctly in user names in ACL lists.
Christopher Kings-Lynne
Diffstat (limited to 'src/bin/pg_dump/dumputils.c')
-rw-r--r--src/bin/pg_dump/dumputils.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index 6bd02419205..0878c80a6ff 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.c,v 1.8 2003/08/04 02:40:09 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/dumputils.c,v 1.9 2003/08/14 14:19:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -557,23 +557,28 @@ static char *
copyAclUserName(PQExpBuffer output, char *input)
{
resetPQExpBuffer(output);
+
while (*input && *input != '=')
{
+ /* If user name isn't quoted, then just add it to the output buffer */
if (*input != '"')
appendPQExpBufferChar(output, *input++);
else
{
+ /* Otherwise, it's a quoted username */
input++;
- while (*input != '"')
+ /* Loop until we come across an unescaped quote */
+ while (!(*input == '"' && *(input + 1) != '"'))
{
if (*input == '\0')
return input; /* really a syntax error... */
/*
- * There is no quoting convention here, thus we can't cope
- * with usernames containing double quotes. Keep this
+ * Quoting convention is to escape " as "". Keep this
* code in sync with putid() in backend's acl.c.
*/
+ if (*input == '"' && *(input + 1) == '"')
+ input++;
appendPQExpBufferChar(output, *input++);
}
input++;