summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TSRM/tsrm_virtual_cwd.c3
-rw-r--r--TSRM/tsrm_virtual_cwd.h3
-rw-r--r--ext/standard/string.c10
3 files changed, 10 insertions, 6 deletions
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index 9c1a5d2925..e0c305d05c 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -364,7 +364,8 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
state->cwd = (char *) realloc(state->cwd, state->cwd_length+ptr_length+1+1);
#ifdef TSRM_WIN32
/* Windows 9x will consider C:\\Foo as a network path. Avoid it. */
- if (state->cwd[state->cwd_length-1]!='\\' && state->cwd[state->cwd_length-1]!='/') {
+ if ((state->cwd[state->cwd_length-1]!='\\' && state->cwd[state->cwd_length-1]!='/') ||
+ IsDBCSLeadByte(state->cwd[state->cwd_length-2])) {
state->cwd[state->cwd_length++] = DEFAULT_SLASH;
}
#else
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index 52afebe0da..98efaa1432 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -50,6 +50,8 @@ typedef unsigned short mode_t;
#define DEFAULT_SLASH '\\'
#define DEFAULT_DIR_SEPARATOR ';'
#define IS_SLASH(c) ((c) == '/' || (c) == '\\')
+#define IS_SLASH_P(c) (*(c) == '/' || \
+ (*(c) == '\\' && !IsDBCSLeadByte(*(c-1))))
#define COPY_WHEN_ABSOLUTE 2
#define IS_ABSOLUTE_PATH(path, len) \
(len >= 2 && isalpha(path[0]) && path[1] == ':')
@@ -70,6 +72,7 @@ typedef unsigned short mode_t;
#endif
#define IS_SLASH(c) ((c) == '/')
+#define IS_SLASH_P(c) (*(c) == '/')
#endif
diff --git a/ext/standard/string.c b/ext/standard/string.c
index f6bda9a231..fd409ee8ad 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1051,7 +1051,7 @@ PHPAPI char *php_basename(char *s, size_t len, char *suffix, size_t sufflen)
/* strip trailing slashes */
while (*c == '/'
#ifdef PHP_WIN32
- || *c == '\\'
+ || (*c == '\\' && !IsDBCSLeadByte(*(c-1)))
#endif
)
c--;
@@ -1063,7 +1063,7 @@ PHPAPI char *php_basename(char *s, size_t len, char *suffix, size_t sufflen)
if ((c = strrchr(s, '/'))
#ifdef PHP_WIN32
- || (c = strrchr(s, '\\'))
+ || ((c = strrchr(s, '\\')) && !IsDBCSLeadByte(*(c-1)))
#endif
) {
ret = estrdup(c + 1);
@@ -1108,7 +1108,7 @@ PHPAPI void php_dirname(char *path, int len)
}
/* Strip trailing slashes */
- while (end >= path && IS_SLASH(*end)) {
+ while (end >= path && IS_SLASH_P(end)) {
end--;
}
if (end < path) {
@@ -1119,7 +1119,7 @@ PHPAPI void php_dirname(char *path, int len)
}
/* Strip filename */
- while (end >= path && !IS_SLASH(*end)) {
+ while (end >= path && !IS_SLASH_P(end)) {
end--;
}
if (end < path) {
@@ -1130,7 +1130,7 @@ PHPAPI void php_dirname(char *path, int len)
}
/* Strip slashes which came before the file name */
- while (end >= path && IS_SLASH(*end)) {
+ while (end >= path && IS_SLASH_P(end)) {
end--;
}
if (end < path) {