From 998299c96cdb5201a263febeb37bfdc3bf4740ef Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Tue, 29 Mar 2005 13:16:47 +0000 Subject: [PATCH] Subsittute ' ' in attachment file names by '_' SVN revision: 1300 --- src/elogd.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/elogd.c b/src/elogd.c index 96d4222a..6e0d0f22 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.607 2005/03/29 13:16:47 ritt + Subsittute ' ' in attachment file names by '_' + Revision 1.606 2005/03/29 11:52:59 ritt Changed is_ascii() to accept umlaute @@ -1936,12 +1939,24 @@ Do the same including '/' characters /*-------------------------------------------------------------------*/ void btou(char *str) -/* convert all blanks and dots to underscores in a string */ +/* convert all blanks to underscores in a string */ { int i; for (i = 0; i < (int) strlen(str); i++) - if (str[i] == ' ' || str[i] == '.') + if (str[i] == ' ') + str[i] = '_'; +} + +/*-------------------------------------------------------------------*/ + +void dtou(char *str) +/* convert all dots to underscores in a string */ +{ + int i; + + for (i = 0; i < (int) strlen(str); i++) + if (str[i] == '.') str[i] = '_'; } @@ -8057,6 +8072,9 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL strcpy(ua, attr_list[i]); btou(ua); + /* convert dots to underscores */ + dtou(ua); + if (attr_flags[i] & AF_MULTI) { rsprintf(" if (\n"); for (j = 0; j < MAX_N_LIST && attr_options[i][j][0]; j++) { @@ -8116,6 +8134,8 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL /* convert blanks to underscores */ strcpy(ua, attr_list[i]); btou(ua); + /* convert dots to underscores */ + dtou(ua); rsprintf(" for (var i=0 ; iname, str, format, sizeof(format))) { @@ -10592,7 +10613,7 @@ void show_new_user_page(LOGBOOK * lbs) /*---- header ----*/ - show_html_header(NULL, TRUE, loc("ELOG new user"), TRUE, FALSE); + show_html_header(lbs, TRUE, loc("ELOG new user"), TRUE, FALSE); rsprintf("

\n"); show_top_text(lbs); rsprintf("

\n\n"); @@ -16888,6 +16909,7 @@ void submit_elog(LOGBOOK * lbs) for (i = 0; i < lbs->n_attr; i++) { strcpy(ua, attr_list[i]); btou(ua); + dtou(ua); if (attr_flags[i] & AF_REQUIRED) { if (attr_flags[i] & AF_DATE) { @@ -16940,6 +16962,7 @@ void submit_elog(LOGBOOK * lbs) if (attr_flags[index] & AF_NUMERIC) { strcpy(ua, attr_list[index]); btou(ua); + dtou(ua); strlcpy(str, getparam(ua), sizeof(str)); for (j = 0; i < (int) strlen(str); i++) @@ -16965,6 +16988,7 @@ void submit_elog(LOGBOOK * lbs) for (i = 0; i < n_attr; i++) { strcpy(ua, attr_list[i]); btou(ua); + dtou(ua); if (attr_flags[i] & AF_MULTI) strcat(ua, "_0"); @@ -17030,6 +17054,7 @@ void submit_elog(LOGBOOK * lbs) strcpy(ua, attr_list[i]); btou(ua); + dtou(ua); if (attr_flags[i] & AF_MULTI) { @@ -17211,6 +17236,7 @@ void submit_elog(LOGBOOK * lbs) strcpy(ua, attr_list[index]); btou(ua); + dtou(ua); if (index < n_attr) { strcpy(str, "Email "); @@ -20584,6 +20610,9 @@ void decode_post(LOGBOOK * lbs, char *string, char *boundary, int length) *strchr(p, '\"') = 0; /* set attachment filename */ strlcpy(file_name, p, sizeof(file_name)); + + /* remove spaces */ + btou(file_name); if (file_name[0]) { if (verbose) eprintf("decode_post: Found attachment %s\n", file_name);