mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-12 16:50:21 +00:00
Merge pull request #191 from kblinova/master
Detect Window's style slashes in mg_upload file names
This commit is contained in:
commit
fa160cb9a3
1 file changed
+4
-2
+4
-2
@@ -4232,9 +4232,11 @@ int mg_upload(struct mg_connection *conn, const char *destination_dir) {
|
|||||||
// there is no other thread can save into the same file simultaneously.
|
// there is no other thread can save into the same file simultaneously.
|
||||||
fp = NULL;
|
fp = NULL;
|
||||||
// Construct destination file name. Do not allow paths to have slashes.
|
// Construct destination file name. Do not allow paths to have slashes.
|
||||||
if ((s = strrchr(fname, '/')) == NULL) {
|
if ((s = strrchr(fname, '/')) == NULL &&
|
||||||
s = fname;
|
(s = strrchr(fname, '\\')) == NULL) {
|
||||||
|
s = fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open file in binary mode. TODO: set an exclusive lock.
|
// Open file in binary mode. TODO: set an exclusive lock.
|
||||||
snprintf(path, sizeof(path), "%s/%s", destination_dir, s);
|
snprintf(path, sizeof(path), "%s/%s", destination_dir, s);
|
||||||
if ((fp = fopen(path, "wb")) == NULL) {
|
if ((fp = fopen(path, "wb")) == NULL) {
|
||||||
|
|||||||
Reference in new issue
Block a user