summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2013-08-15 16:37:06 +0000
committerKinsey Moore <kmoore@digium.com>2013-08-15 16:37:06 +0000
commitbd352e0827f9df2290599bb6bcb2f819ca7b5ee6 (patch)
treeded22591989a01f4a4443e9cd2cc5abc5540b5e7 /main
parent6d24165deef959b5eed2733497da524958ce82b5 (diff)
Remove leading spaces from the CLI command before parsing
If you've mistakenly put a space before typing in a command, the leading space will be included as part of the command, and the command parser will not find the corresponding command. This patch rectifies that situation by stripping the leading spaces on commands. Review: https://reviewboard.asterisk.org/r/2709/ Patch-by: Tilghman Lesher ........ Merged revisions 396745 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 396746 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396747 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/asterisk.c5
-rw-r--r--main/cli.c7
2 files changed, 12 insertions, 0 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index beed01083..07186f655 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -2112,6 +2112,11 @@ static int remoteconsolehandler(char *s)
/* Called when readline data is available */
if (!ast_all_zeros(s))
ast_el_add_history(s);
+
+ while (isspace(*s)) {
+ s++;
+ }
+
/* The real handler for bang */
if (s[0] == '!') {
if (s[1])
diff --git a/main/cli.c b/main/cli.c
index dd9f3bcd0..54efd6f4c 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -2292,6 +2292,13 @@ static char *parse_args(const char *s, int *argc, const char *argv[], int max, i
return NULL;
cur = duplicate;
+
+ /* Remove leading spaces from the command */
+ while (isspace(*s)) {
+ cur++;
+ s++;
+ }
+
/* scan the original string copying into cur when needed */
for (; *s ; s++) {
if (x >= max - 1) {