mirror of
https://github.com/rkd77/elinks.git
synced 2025-06-30 22:19:29 -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:
parent
5b9ea6a4ee
commit
dbfb34f395
@ -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
|
instance, but instead connects to an already running ELinks, making it
|
||||||
possible to control that ELinks instance. The -remote command line switch
|
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
|
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)"
|
$ elinks -remote "openURL(http://freshmeat.net/, new-tab)"
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ remote_cmd(struct option *o, unsigned char ***argv, int *argc)
|
|||||||
{ "xfeDoCommand", REMOTE_METHOD_XFEDOCOMMAND },
|
{ "xfeDoCommand", REMOTE_METHOD_XFEDOCOMMAND },
|
||||||
{ NULL, REMOTE_METHOD_NOT_SUPPORTED },
|
{ NULL, REMOTE_METHOD_NOT_SUPPORTED },
|
||||||
};
|
};
|
||||||
unsigned char *command, *arg, *argend = NULL;
|
unsigned char *command, *arg, *argend;
|
||||||
int method, len = 0;
|
int method, len = 0;
|
||||||
|
|
||||||
if (*argc < 1) return gettext("Parameter expected");
|
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]))
|
while (isalpha(command[len]))
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
arg = strchr(&command[len], '(');
|
/* Find the begining and end of the argument list. */
|
||||||
if (arg) {
|
|
||||||
arg++;
|
|
||||||
skip_space(arg);
|
|
||||||
|
|
||||||
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 */
|
/* Just open any passed URLs in new tabs */
|
||||||
remote_session_flags |= SES_REMOTE_NEW_TAB;
|
remote_session_flags |= SES_REMOTE_NEW_TAB;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Skip parenthesis and surrounding whitespace. */
|
||||||
|
arg++;
|
||||||
|
skip_space(arg);
|
||||||
skipback_whitespace(arg, argend);
|
skipback_whitespace(arg, argend);
|
||||||
|
|
||||||
for (method = 0; remote_methods[method].name; method++) {
|
for (method = 0; remote_methods[method].name; method++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user