mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Fix invalid file name characters handling on Windows
This commit is contained in:
parent
5e253785af
commit
e49d928ce4
7
CHANGES
7
CHANGES
@ -6,6 +6,13 @@
|
|||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Yang Tse (17 Oct 2009)
|
||||||
|
- Bug report #2866724 indicated
|
||||||
|
(http://curl.haxx.se/bug/view.cgi?id=2866724) that curl on Windows failed
|
||||||
|
when writing files whose file names originally contained characters which
|
||||||
|
are not valid for file names on Windows. Dan Fandrich provided an initial
|
||||||
|
patch and another revised one to fix this issue.
|
||||||
|
|
||||||
Daniel Stenberg (1 Oct 2009)
|
Daniel Stenberg (1 Oct 2009)
|
||||||
- Tom Mueller correctly reported in bug report #2870221
|
- Tom Mueller correctly reported in bug report #2870221
|
||||||
(http://curl.haxx.se/bug/view.cgi?id=2870221) that libcurl returned an
|
(http://curl.haxx.se/bug/view.cgi?id=2870221) that libcurl returned an
|
||||||
|
@ -35,6 +35,7 @@ This release includes the following bugfixes:
|
|||||||
query part
|
query part
|
||||||
o don't shrink SO_SNDBUF on windows for those who have it set large already
|
o don't shrink SO_SNDBUF on windows for those who have it set large already
|
||||||
o connect next bug
|
o connect next bug
|
||||||
|
o invalid file name characters handling on Windows
|
||||||
|
|
||||||
This release includes the following known bugs:
|
This release includes the following known bugs:
|
||||||
|
|
||||||
@ -46,6 +47,6 @@ advice from friends like these:
|
|||||||
Karl Moerder, Kamil Dudka, Krister Johansen, Andre Guibert de Bruet,
|
Karl Moerder, Kamil Dudka, Krister Johansen, Andre Guibert de Bruet,
|
||||||
Michal Marek, Eric Wong, Guenter Knauf, Peter Sylvester, Daniel Johnson,
|
Michal Marek, Eric Wong, Guenter Knauf, Peter Sylvester, Daniel Johnson,
|
||||||
Claes Jakobsson, Sven Anders, Chris Mumford, John P. McCaskey,
|
Claes Jakobsson, Sven Anders, Chris Mumford, John P. McCaskey,
|
||||||
Constantine Sapuntzakis, Michael Stillwell, Tom Mueller
|
Constantine Sapuntzakis, Michael Stillwell, Tom Mueller, Dan Fandrich,
|
||||||
|
|
||||||
Thanks! (and sorry if I forgot to mention someone)
|
Thanks! (and sorry if I forgot to mention someone)
|
||||||
|
59
src/main.c
59
src/main.c
@ -158,13 +158,31 @@ static int vms_show = 0;
|
|||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MSDOS
|
#if defined(MSDOS) || defined(WIN32)
|
||||||
#define USE_WATT32
|
|
||||||
#include <dos.h>
|
|
||||||
|
|
||||||
static const char *msdosify(const char *);
|
static const char *msdosify(const char *);
|
||||||
static char *rename_if_dos_device_name(char *);
|
static char *rename_if_dos_device_name(char *);
|
||||||
|
|
||||||
|
#ifndef S_ISCHR
|
||||||
|
# ifdef S_IFCHR
|
||||||
|
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||||
|
# else
|
||||||
|
# define S_ISCHR(m) (0) /* cannot tell if file is a device */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
# define _use_lfn(f) (1) /* long file names always available */
|
||||||
|
#elif !defined(__DJGPP__) || (__DJGPP__ < 2) /* DJGPP 2.0 has _use_lfn() */
|
||||||
|
# define _use_lfn(f) (0) /* long file names never available */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* MSDOS || WIN32 */
|
||||||
|
|
||||||
|
#ifdef MSDOS
|
||||||
|
#define USE_WATT32
|
||||||
|
#include <dos.h>
|
||||||
|
|
||||||
#ifdef DJGPP
|
#ifdef DJGPP
|
||||||
/* we want to glob our own argv[] */
|
/* we want to glob our own argv[] */
|
||||||
char **__crt0_glob_function (char *arg)
|
char **__crt0_glob_function (char *arg)
|
||||||
@ -200,12 +218,6 @@ typedef enum {
|
|||||||
HTTPREQ_LAST
|
HTTPREQ_LAST
|
||||||
} HttpReq;
|
} HttpReq;
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include <direct.h>
|
|
||||||
#define F_OK 0
|
|
||||||
#define mkdir(x,y) (mkdir)(x)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Large file support (>2Gb) using WIN32 functions.
|
* Large file support (>2Gb) using WIN32 functions.
|
||||||
*/
|
*/
|
||||||
@ -244,6 +256,14 @@ typedef enum {
|
|||||||
# define LSEEK_ERROR (off_t)-1
|
# define LSEEK_ERROR (off_t)-1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
# include <direct.h>
|
||||||
|
# define F_OK 0
|
||||||
|
# define mkdir(x,y) (mkdir)(x)
|
||||||
|
# undef PATH_MAX
|
||||||
|
# define PATH_MAX MAX_PATH
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default sizeof(off_t) in case it hasn't been defined in config file.
|
* Default sizeof(off_t) in case it hasn't been defined in config file.
|
||||||
*/
|
*/
|
||||||
@ -4350,9 +4370,9 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
free(url);
|
free(url);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if defined(MSDOS)
|
#if defined(MSDOS) || defined(WIN32)
|
||||||
{
|
{
|
||||||
/* This is for DOS, and then we do some major replacing of
|
/* For DOS and WIN32, we do some major replacing of
|
||||||
bad characters in the file name before using it */
|
bad characters in the file name before using it */
|
||||||
char file1[PATH_MAX];
|
char file1[PATH_MAX];
|
||||||
if(strlen(outfile) >= PATH_MAX)
|
if(strlen(outfile) >= PATH_MAX)
|
||||||
@ -4366,7 +4386,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* MSDOS */
|
#endif /* MSDOS || WIN32 */
|
||||||
}
|
}
|
||||||
else if(urls) {
|
else if(urls) {
|
||||||
/* fill '#1' ... '#9' terms from URL pattern */
|
/* fill '#1' ... '#9' terms from URL pattern */
|
||||||
@ -5411,7 +5431,7 @@ static int create_dir_hierarchy(const char *outfile, FILE *errors)
|
|||||||
return result; /* 0 is fine, -1 is badness */
|
return result; /* 0 is fine, -1 is badness */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MSDOS
|
#if defined(MSDOS) || defined(WIN32)
|
||||||
|
|
||||||
#ifndef HAVE_BASENAME
|
#ifndef HAVE_BASENAME
|
||||||
/* basename() returns a pointer to the last component of a pathname.
|
/* basename() returns a pointer to the last component of a pathname.
|
||||||
@ -5455,14 +5475,9 @@ msdosify (const char *file_name)
|
|||||||
const char * const dlimit = dos_name + sizeof(dos_name) - 1;
|
const char * const dlimit = dos_name + sizeof(dos_name) - 1;
|
||||||
const char *illegal_aliens = illegal_chars_dos;
|
const char *illegal_aliens = illegal_chars_dos;
|
||||||
size_t len = sizeof (illegal_chars_dos) - 1;
|
size_t len = sizeof (illegal_chars_dos) - 1;
|
||||||
int lfn = 0;
|
|
||||||
|
|
||||||
#ifdef DJGPP
|
/* Support for Windows 9X VFAT systems, when available. */
|
||||||
/* Support for Windows 9X VFAT systems, when available (djgpp only). */
|
if (_use_lfn (file_name)) {
|
||||||
if (_use_lfn (file_name))
|
|
||||||
lfn = 1;
|
|
||||||
#endif
|
|
||||||
if (lfn) {
|
|
||||||
illegal_aliens = illegal_chars_w95;
|
illegal_aliens = illegal_chars_w95;
|
||||||
len -= (illegal_chars_w95 - illegal_chars_dos);
|
len -= (illegal_chars_w95 - illegal_chars_dos);
|
||||||
}
|
}
|
||||||
@ -5541,7 +5556,7 @@ rename_if_dos_device_name (char *file_name)
|
|||||||
* retrieve such a file would fail at best and wedge us at worst. We need
|
* retrieve such a file would fail at best and wedge us at worst. We need
|
||||||
* to rename such files. */
|
* to rename such files. */
|
||||||
char *base;
|
char *base;
|
||||||
struct stat st_buf;
|
struct_stat st_buf;
|
||||||
char fname[PATH_MAX];
|
char fname[PATH_MAX];
|
||||||
|
|
||||||
strncpy(fname, file_name, PATH_MAX-1);
|
strncpy(fname, file_name, PATH_MAX-1);
|
||||||
@ -5562,4 +5577,4 @@ rename_if_dos_device_name (char *file_name)
|
|||||||
}
|
}
|
||||||
return file_name;
|
return file_name;
|
||||||
}
|
}
|
||||||
#endif /* MSDOS */
|
#endif /* MSDOS || WIN32 */
|
||||||
|
Loading…
Reference in New Issue
Block a user