mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-10 18:23:28 +00:00
Fixed problem with logbooks containing blanks
SVN revision: 860
This commit is contained in:
parent
43d8311eae
commit
21a3e616b3
37
src/elog.c
37
src/elog.c
@ -6,6 +6,9 @@
|
|||||||
Contents: Electronic logbook utility
|
Contents: Electronic logbook utility
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.20 2004/03/28 10:41:05 midas
|
||||||
|
Fixed problem with logbooks containing blanks
|
||||||
|
|
||||||
Revision 1.19 2004/03/26 08:28:29 midas
|
Revision 1.19 2004/03/26 08:28:29 midas
|
||||||
Version 2.5.2
|
Version 2.5.2
|
||||||
|
|
||||||
@ -260,6 +263,33 @@ void btou(char *str)
|
|||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void url_encode(char *ps, int size)
|
||||||
|
/********************************************************************\
|
||||||
|
Encode the given string in-place by adding %XX escapes
|
||||||
|
\********************************************************************/
|
||||||
|
{
|
||||||
|
unsigned char *pd, *p, str[NAME_LENGTH];
|
||||||
|
|
||||||
|
pd = str;
|
||||||
|
p = ps;
|
||||||
|
while (*p && (int) pd < (int) str + 250) {
|
||||||
|
if (strchr("%&=#?+", *p) || *p > 127) {
|
||||||
|
sprintf(pd, "%%%02X", *p);
|
||||||
|
pd += 3;
|
||||||
|
p++;
|
||||||
|
} else if (*p == ' ') {
|
||||||
|
*pd++ = '+';
|
||||||
|
p++;
|
||||||
|
} else {
|
||||||
|
*pd++ = *p++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*pd = '\0';
|
||||||
|
strlcpy(ps, str, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
void sgets(char *string, int size)
|
void sgets(char *string, int size)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
@ -818,8 +848,11 @@ INT submit_elog(char *host, int port, char *subdir, char *experiment,
|
|||||||
strcpy(request, "POST /");
|
strcpy(request, "POST /");
|
||||||
if (subdir[0])
|
if (subdir[0])
|
||||||
sprintf(request + strlen(request), "%s/", subdir);
|
sprintf(request + strlen(request), "%s/", subdir);
|
||||||
if (experiment[0])
|
if (experiment[0]) {
|
||||||
sprintf(request + strlen(request), "%s/", experiment);
|
strcpy(str, experiment);
|
||||||
|
url_encode(str, sizeof(str));
|
||||||
|
sprintf(request + strlen(request), "%s/", str);
|
||||||
|
}
|
||||||
strcat(request, " HTTP/1.0\r\n");
|
strcat(request, " HTTP/1.0\r\n");
|
||||||
|
|
||||||
sprintf(request + strlen(request),
|
sprintf(request + strlen(request),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user