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 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'nx-X11/programs/Xserver/hw/nxagent/Args.c') 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") || -- cgit v1.2.3