1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Prevent evaluation of backticks while discarding unwanted arguments

after an unknown or failed psql backslash command, and also while
discarding "extra" arguments of a putatively valid backslash command.
In the case of an unknown/failed command, make sure we discard the
whole rest of the line, rather than trying to resume at the next
backslash.  Per discussion with Thomer Gil.
This commit is contained in:
Tom Lane
2004-12-19 19:39:47 +00:00
parent cd5c7e7cbd
commit 1553be4a0b
3 changed files with 46 additions and 21 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.137 2004/11/30 20:00:34 momjian Exp $
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.138 2004/12/19 19:39:47 tgl Exp $
*/
#include "postgres_fe.h"
#include "command.h"
@ -127,13 +127,23 @@ HandleSlashCmds(PsqlScanState scan_state,
status = CMD_ERROR;
}
/* eat the rest of the options, if any */
while ((arg = psql_scan_slash_option(scan_state,
OT_NORMAL, NULL, false)))
if (status != CMD_ERROR)
{
if (status != CMD_ERROR)
/* eat any remaining arguments after a valid command */
/* note we suppress evaluation of backticks here */
while ((arg = psql_scan_slash_option(scan_state,
OT_VERBATIM, NULL, false)))
{
psql_error("\\%s: extra argument \"%s\" ignored\n", cmd, arg);
free(arg);
free(arg);
}
}
else
{
/* silently throw away rest of line after an erroneous command */
while ((arg = psql_scan_slash_option(scan_state,
OT_WHOLE_LINE, NULL, false)))
free(arg);
}
/* if there is a trailing \\, swallow it */