Skip to content

Commit 30a9627

Browse files
uli42sunweaver
authored andcommitted
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.
1 parent f8e20d0 commit 30a9627

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

nx-X11/programs/Xserver/hw/nxagent/Args.c

+35
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,39 @@ int ddxProcessArgument(int argc, char *argv[], int i)
10371037
return 0;
10381038
}
10391039

1040+
/* copy from nxcomp's Loop.cpp */
1041+
static int
1042+
hexval(char c) {
1043+
if ((c >= '0') && (c <= '9'))
1044+
return c - '0';
1045+
if ((c >= 'a') && (c <= 'f'))
1046+
return c - 'a' + 10;
1047+
if ((c >= 'A') && (c <= 'F'))
1048+
return c - 'A' + 10;
1049+
return -1;
1050+
}
1051+
1052+
static void
1053+
URLDecodeInPlace(char *str)
1054+
{
1055+
if (str) {
1056+
char *to = str;
1057+
while (str[0])
1058+
{
1059+
if ((str[0] == '%') &&
1060+
(hexval(str[1]) >= 0) &&
1061+
(hexval(str[2]) >= 0))
1062+
{
1063+
*(to++) = hexval(str[1]) * 16 + hexval(str[2]);
1064+
str += 3;
1065+
}
1066+
else
1067+
*(to++) = *(str++);
1068+
}
1069+
*to = '\0';
1070+
}
1071+
}
1072+
10401073
static void nxagentParseSingleOption(char *name, char *value)
10411074
{
10421075
int size, argc;
@@ -1048,6 +1081,8 @@ static void nxagentParseSingleOption(char *name, char *value)
10481081
validateString(name), validateString(value));
10491082
#endif
10501083

1084+
URLDecodeInPlace(value);
1085+
10511086
if (!strcmp(name, "kbtype") ||
10521087
!strcmp(name, "keyboard") ||
10531088
!strcmp(name, "id") ||

nx-X11/programs/Xserver/hw/nxagent/man/nxagent.1

+5
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,11 @@ As <proxy-port> you can pick an arbitrary (unused) TCP port or Unix
480480
socket file path. This is the port / socket that you have to connect to
481481
with the \fBnxproxy\fR application.
482482
.PP
483+
The right hand side of an option (the part following the "=" character)
484+
can include URL encoded characters. It is required to URL encode at
485+
least "," (as %2D) and "=" (as %3D) to avoid wrong parsing of the
486+
options string.
487+
.PP
483488
Available \fBnxagent\fR options (as an addition to nx/nx options supported
484489
by nxcomp already):
485490
.TP 8

0 commit comments

Comments
 (0)