Fix execute to filter input just like the main command loop
When we added input filtering in v4.2.21, we missed the execute command. Because of that, funny characters can be treated differently in batch files. The main command loop uses getcommand(), which filters input. execute() uses recvclient() directly, and doesn't filter input. Both feed the command to parse(), which drops unwanted control and non-ASCII characters. Input filtering drops unwanted control characters and, for ASCII sessions, replaces non-ASCII characters by '?'. Because of that, execute in ASCII sessions drops non-ASCII command characters in batch files rather than replacing them. Except where parts of the command are used raw: execute's command echo, flash and wall message argument. There, unwanted control characters aren't dropped in UTF-8 sessions, and non-ASCII characters are interpreted as UTF-8 in ASCII sessions. Output filtering replaces any resulting non-ASCII characters. players column "last command" also uses the command raw, but commands executed from batch files are not visible there, so it isn't affected. To get rid of the differences, move the prompting from getcommand() to command(), then switch execute() over to getcommand(). Side effect: the batch file's commands are now recorded in player_commands[]. That's desirable.
This commit is contained in:
parent
a9611a5794
commit
e2e69a29d5
2 changed files with 4 additions and 4 deletions
|
@ -69,10 +69,8 @@ static void disable_coms(void);
|
||||||
int
|
int
|
||||||
getcommand(char *combufp)
|
getcommand(char *combufp)
|
||||||
{
|
{
|
||||||
struct natstr *natp = getnatp(player->cnum);
|
|
||||||
char buf[1024]; /* user text */
|
char buf[1024]; /* user text */
|
||||||
|
|
||||||
prprompt(natp->nat_timeused / 60, natp->nat_btu);
|
|
||||||
if (recvclient(buf, sizeof(buf)) < 0)
|
if (recvclient(buf, sizeof(buf)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
|
@ -115,16 +115,18 @@ player_main(struct player *p)
|
||||||
static int
|
static int
|
||||||
command(void)
|
command(void)
|
||||||
{
|
{
|
||||||
|
struct natstr *natp = getnatp(player->cnum);
|
||||||
char *redir; /* UTF-8 */
|
char *redir; /* UTF-8 */
|
||||||
char scanspace[1024];
|
char scanspace[1024];
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
|
prprompt(natp->nat_timeused / 60, natp->nat_btu);
|
||||||
if (getcommand(player->combuf) < 0)
|
if (getcommand(player->combuf) < 0)
|
||||||
return player->aborted;
|
return player->aborted;
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
update_timeused(now);
|
update_timeused(now);
|
||||||
if (!player->god && !may_play_now(getnatp(player->cnum), now))
|
if (!player->god && !may_play_now(natp, now))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (parse(player->combuf, scanspace, player->argp, player->comtail,
|
if (parse(player->combuf, scanspace, player->argp, player->comtail,
|
||||||
|
@ -255,7 +257,7 @@ execute(void)
|
||||||
|
|
||||||
while (!failed && status()) {
|
while (!failed && status()) {
|
||||||
player->nstat &= ~EXEC;
|
player->nstat &= ~EXEC;
|
||||||
if (recvclient(buf, sizeof(buf)) < 0)
|
if (getcommand(buf) < 0)
|
||||||
break;
|
break;
|
||||||
if (parse(buf, scanspace, player->argp, player->comtail,
|
if (parse(buf, scanspace, player->argp, player->comtail,
|
||||||
&player->condarg, &redir) < 0) {
|
&player->condarg, &redir) < 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue