From f8e20d05f527daeb8e42e366ca2ebe1546b061df Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Aug 2018 23:08:30 +0200 Subject: Args.c: rename nxagentParseOptions to nxagentParseSingleOption new name is more descriptive --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 262c1dfdb..30e3b8692 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -1037,14 +1037,14 @@ int ddxProcessArgument(int argc, char *argv[], int i) return 0; } -static void nxagentParseOptions(char *name, char *value) +static void nxagentParseSingleOption(char *name, char *value) { int size, argc; char *argv[2] = { NULL, NULL }; #ifdef TEST - fprintf(stderr, "nxagentParseOptions: Processing option '%s' = '%s'.\n", + fprintf(stderr, "nxagentParseSingleOption: Processing option '%s' = '%s'.\n", validateString(name), validateString(value)); #endif @@ -1081,7 +1081,7 @@ static void nxagentParseOptions(char *name, char *value) if (nxagentReconnectTrap == True) { #ifdef DEBUG - fprintf(stderr, "nxagentParseOptions: Ignoring option 'render' at reconnection.\n"); + fprintf(stderr, "nxagentParseSingleOption: Ignoring option 'render' at reconnection.\n"); #endif } else if (nxagentRenderEnable == UNDEFINED) @@ -1113,7 +1113,7 @@ static void nxagentParseOptions(char *name, char *value) if (nxagentReconnectTrap == True) { #ifdef DEBUG - fprintf(stderr, "nxagentParseOptions: Ignoring option 'fullscreen' at reconnection.\n"); + fprintf(stderr, "nxagentParseSingleOption: Ignoring option 'fullscreen' at reconnection.\n"); #endif } else if (!strcmp(value, "1")) @@ -1283,7 +1283,7 @@ static void nxagentParseOptions(char *name, char *value) if (nxagentReconnectTrap == True) { #ifdef DEBUG - fprintf(stderr, "nxagentParseOptions: Ignoring option 'autodpi' at reconnection.\n"); + fprintf(stderr, "nxagentParseSingleOption: Ignoring option 'autodpi' at reconnection.\n"); #endif } else if (!strcmp(value, "0")) @@ -1368,7 +1368,7 @@ static void nxagentParseOptions(char *name, char *value) if ((errno) && (0 == sleep_parse)) { - fprintf(stderr, "nxagentParseOptions: Unable to convert value [%s] of option [%s]. " + fprintf(stderr, "nxagentParseSingleOption: Unable to convert value [%s] of option [%s]. " "Ignoring option.\n", validateString(value), validateString(name)); @@ -1379,7 +1379,7 @@ static void nxagentParseOptions(char *name, char *value) { sleep_parse = UINT_MAX; - fprintf(stderr, "nxagentParseOptions: Warning: value [%s] of option [%s] " + fprintf(stderr, "nxagentParseSingleOption: Warning: value [%s] of option [%s] " "out of range, clamped to [%lu].\n", validateString(value), validateString(name), sleep_parse); } @@ -1388,7 +1388,7 @@ static void nxagentParseOptions(char *name, char *value) { sleep_parse = 0; - fprintf(stderr, "nxagentParseOptions: Warning: value [%s] of option [%s] " + fprintf(stderr, "nxagentParseSingleOption: Warning: value [%s] of option [%s] " "out of range, clamped to [%lu].\n", validateString(value), validateString(name), sleep_parse); } @@ -1427,7 +1427,7 @@ static void nxagentParseOptions(char *name, char *value) if ((errno) && (0 == tolerance_parse)) { - fprintf(stderr, "nxagentParseOptions: Unable to convert value [%s] of option [%s]. " + fprintf(stderr, "nxagentParseSingleOption: Unable to convert value [%s] of option [%s]. " "Ignoring option.\n", validateString(value), validateString(name)); @@ -1438,7 +1438,7 @@ static void nxagentParseOptions(char *name, char *value) { tolerance_parse = UINT_MAX; - fprintf(stderr, "nxagentParseOptions: Warning: value [%s] of option [%s] " + fprintf(stderr, "nxagentParseSingleOption: Warning: value [%s] of option [%s] " "out of range, clamped to [%lu].\n", validateString(value), validateString(name), tolerance_parse); } @@ -1447,7 +1447,7 @@ static void nxagentParseOptions(char *name, char *value) { tolerance_parse = 0; - fprintf(stderr, "nxagentParseOptions: Warning: value [%s] of option [%s] " + fprintf(stderr, "nxagentParseSingleOption: Warning: value [%s] of option [%s] " "out of range, clamped to [%lu].\n", validateString(value), validateString(name), tolerance_parse); } @@ -1460,7 +1460,7 @@ static void nxagentParseOptions(char *name, char *value) case ToleranceChecksBypass: break; default: - fprintf(stderr, "nxagentParseOptions: Warning: value [%s] of " + fprintf(stderr, "nxagentParseSingleOption: Warning: value [%s] of " "option [%s] unknown, will be mapped to " "\"Bypass\" [%u] value internally.\n", validateString(value), validateString(name), @@ -1495,7 +1495,7 @@ static void nxagentParseOptions(char *name, char *value) else { #ifdef DEBUG - fprintf(stderr, "nxagentParseOptions: Ignored option [%s] with value [%s].\n", + fprintf(stderr, "nxagentParseSingleOption: Ignored option [%s] with value [%s].\n", validateString(name), validateString(value)); #endif @@ -1563,7 +1563,7 @@ static void nxagentParseOptionString(char *string) value = NULL; } - nxagentParseOptions(option, value); + nxagentParseSingleOption(option, value); } } -- cgit v1.2.3 From 30a96273380a53320c8950f945b1f52c111337ce Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 23 Aug 2018 23:09:44 +0200 Subject: Args.c: allow options to contain URL encoded characters Same as in nxcomp's option handling. We really only need it for "," (%2C) and "=" (%3D), currently, but it can handle all encoded characters. --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 35 ++++++++++++++++++++++++ nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 | 5 ++++ 2 files changed, 40 insertions(+) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 30e3b8692..801ee0b22 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -1037,6 +1037,39 @@ int ddxProcessArgument(int argc, char *argv[], int i) return 0; } +/* copy from nxcomp's Loop.cpp */ +static int +hexval(char c) { + if ((c >= '0') && (c <= '9')) + return c - '0'; + if ((c >= 'a') && (c <= 'f')) + return c - 'a' + 10; + if ((c >= 'A') && (c <= 'F')) + return c - 'A' + 10; + return -1; +} + +static void +URLDecodeInPlace(char *str) +{ + if (str) { + char *to = str; + while (str[0]) + { + if ((str[0] == '%') && + (hexval(str[1]) >= 0) && + (hexval(str[2]) >= 0)) + { + *(to++) = hexval(str[1]) * 16 + hexval(str[2]); + str += 3; + } + else + *(to++) = *(str++); + } + *to = '\0'; + } +} + static void nxagentParseSingleOption(char *name, char *value) { int size, argc; @@ -1048,6 +1081,8 @@ static void nxagentParseSingleOption(char *name, char *value) validateString(name), validateString(value)); #endif + URLDecodeInPlace(value); + if (!strcmp(name, "kbtype") || !strcmp(name, "keyboard") || !strcmp(name, "id") || diff --git a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 index b9c81cdb4..6a0bfc103 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 +++ b/nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1 @@ -480,6 +480,11 @@ As you can pick an arbitrary (unused) TCP port or Unix socket file path. This is the port / socket that you have to connect to with the \fBnxproxy\fR application. .PP +The right hand side of an option (the part following the "=" character) +can include URL encoded characters. It is required to URL encode at +least "," (as %2D) and "=" (as %3D) to avoid wrong parsing of the +options string. +.PP Available \fBnxagent\fR options (as an addition to nx/nx options supported by nxcomp already): .TP 8 -- cgit v1.2.3