diff --git a/scriptcontext.c b/scriptcontext.c index 74eb901f..cf5c7634 100644 --- a/scriptcontext.c +++ b/scriptcontext.c @@ -402,6 +402,7 @@ static char *SctActionHandler(void *actionData, char *lastReply, char *errorScript = NULL; char *send = NULL; int i; + int j; SConnection *con; char eprop[80]; char msg[1024]; @@ -516,6 +517,21 @@ static char *SctActionHandler(void *actionData, char *lastReply, if (strcasecmp(data->name, "read") == 0) { SetHdbProperty(node, "geterror", result); } + /* Sanitize the text to reduce TCL problems with unbalanced and substituted items */ + for (j = 0; msg[j]; ++j) { + switch (msg[j]) { + case '{': + case '}': + case '[': + case ']': + case '<': + case '>': + case '\'': + case '"': + case '$': + msg[j] = '_'; + } + } SetHdbProperty(node, eprop, msg); blank = strchr(origScript, ' '); if (blank != NULL) { @@ -531,6 +547,21 @@ static char *SctActionHandler(void *actionData, char *lastReply, } cnt++; snprintf(msg, sizeof msg, "%dx {%s}: %s", cnt, origScript, result); + /* Sanitize the text to reduce TCL problems with unbalanced and substituted items */ + for (j = 0; msg[j]; ++j) { + switch (msg[j]) { + case '{': + case '}': + case '[': + case ']': + case '<': + case '>': + case '\'': + case '"': + case '$': + msg[j] = '_'; + } + } SetHdbProperty(node, eprop, msg); send = NULL; free(script);