]> code.citadel.org Git - citadel.git/blobdiff - citadel/routines2.c
* routines2.c: fixed an off-by-one error in filename sanitization for
[citadel.git] / citadel / routines2.c
index 7c5821e7f62a6283f489885a0ffa44939be23cb9..efc81a6e202df26cb03c060f18c97b084c33d215 100644 (file)
@@ -257,10 +257,13 @@ void cli_upload(CtdlIPC *ipc)
                /* basename of filename */
                strcpy(tbuf, flnm);
                if (haschar(tbuf, '/'))
-                       strcpy(tbuf, strrchr(tbuf, '/'));
+                       extract_token(tbuf, flnm,
+                               num_tokens(tbuf, '/') - 1,
+                               '/'
+                       );
                /* filename.1, filename.2, etc */
                if (a > 0) {
-                       sprintf(buf + strlen(buf), ".%d", a);
+                       sprintf(&tbuf[strlen(tbuf)], ".%d", a);
                }
                /* Try upload */
                r = CtdlIPCFileUpload(ipc, tbuf, desc, flnm, progress, buf);
@@ -269,7 +272,8 @@ void cli_upload(CtdlIPC *ipc)
                else
                        break;
                ++a;
-       };
+       }
+       if (a > 0) scr_printf("Saved as '%s'\n", tbuf);
 }