1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-07-26 16:45:12 -04:00

Fix misparsing of -remote URLs containing parenthesis (bug 830)

Be more strict about the format accepted by the ELinks specific extension
to the -remote URL syntax. That is, commands must begin with a nonempty
sequence of ASCII alphabetic characters followed by optional whitespace and
an opening parenthesis. Also, document the syntax.

Fixes bug 830.
This commit is contained in:
Jonas Fonseca 2006-11-12 18:48:16 +01:00
parent cb02b46154
commit 89fd7efa3a
2 changed files with 19 additions and 9 deletions

View File

@ -10,7 +10,10 @@ When invoking ELinks with the -remote argument, it does not start a new
instance, but instead connects to an already running ELinks, making it
possible to control that ELinks instance. The -remote command line switch
takes a command consisting of the action to invoke and any parameters to the
action. Here is an example for opening freshmeat.net in a new tab:
action. Commands must begin with a nonempty sequence of ASCII alphabetic
characters followed by optional whitespace and an opening parenthesis. They
must end with a closing parenthesis optionally followed by whitespace. Here is
an example for opening freshmeat.net in a new tab:
$ elinks -remote "openURL(http://freshmeat.net/, new-tab)"

View File

@ -218,7 +218,7 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc)
{ "xfeDoCommand", REMOTE_METHOD_XFEDOCOMMAND },
{ NULL, REMOTE_METHOD_NOT_SUPPORTED },
};
unsigned char *command, *arg, *argend = NULL;
unsigned char *command, *arg, *argend;
int method, len = 0;
if (*argc < 1) return gettext("Parameter expected");
@ -228,20 +228,27 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc)
while (isalpha(command[len]))
len++;
arg = strchr(&command[len], '(');
if (arg) {
arg++;
skip_space(arg);
/* Find the begining and end of the argument list. */
argend = strchr(arg, ')');
}
arg = command + len;
skip_space(arg);
if (!argend) {
argend = arg + strlen(arg);
skipback_whitespace(arg, argend);
if (argend > arg)
argend--;
/* Decide whether to use the "extended" --remote format where
* all URLs following should be opened in tabs. */
if (*arg != '(' || *argend != ')') {
/* Just open any passed URLs in new tabs */
remote_session_flags |= SES_REMOTE_NEW_TAB;
return NULL;
}
/* Skip parenthesis and surrounding whitespace. */
arg++;
skip_space(arg);
skipback_whitespace(arg, argend);
for (method = 0; remote_methods[method].name; method++) {