goto unsafe;
}
- if (p[0] == '.' && len == 3 && p[1] == '.' && (p[2] == '/'
-#if (NGX_WIN32)
- || p[2] == '\\'
-#endif
- ))
- {
+ if (p[0] == '.' && len == 3 && p[1] == '.' && (ngx_path_separator(p[2]))) {
goto unsafe;
}
continue;
}
- if ((ch == '/'
-#if (NGX_WIN32)
- || ch == '\\'
-#endif
- ) && len > 2)
- {
+ if (ngx_path_separator(ch) && len > 2) {
+
/* detect "/../" */
- if (p[0] == '.' && p[1] == '.' && p[2] == '/') {
+ if (p[0] == '.' && p[1] == '.' && ngx_path_separator(p[2])) {
goto unsafe;
}
#if (NGX_WIN32)
- if (p[2] == '\\') {
- goto unsafe;
- }
-
if (len > 3) {
/* detect "/.../" */
if (p[0] == '.' && p[1] == '.' && p[2] == '.'
- && (p[3] == '/' || p[3] == '\\'))
+ && ngx_path_separator(p[3]))
{
goto unsafe;
}
continue;
}
- if (ch == '/' || ch == '\0') {
+ if (ngx_path_separator(ch) || ch == '\0') {
return -1;
}
-
-#if (NGX_WIN32)
- if (ch == '\\') {
- return -1;
- }
-#endif
}
if (dot) {
#define ngx_realpath_n "realpath()"
#define ngx_getcwd(buf, size) (getcwd(buf, size) != NULL)
#define ngx_getcwd_n "getcwd()"
+#define ngx_path_separator(c) ((c) == '/')
+
#define NGX_MAX_PATH PATH_MAX
#define NGX_DIR_MASK_LEN 0
#define ngx_realpath_n ""
#define ngx_getcwd(buf, size) GetCurrentDirectory(size, buf)
#define ngx_getcwd_n "GetCurrentDirectory()"
+#define ngx_path_separator(c) ((c) == '/' || (c) == '\\')
+
#define NGX_MAX_PATH MAX_PATH