diff --git a/ext/standard/string.c b/ext/standard/string.c index 00881383aa2..47b4f60f0fe 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1429,7 +1429,7 @@ PHPAPI void php_basename(const char *s, size_t len, char *suffix, size_t sufflen goto quit_loop; case 1: #if defined(PHP_WIN32) || defined(NETWARE) - if (*c == '/' || *c == '\\') { + if (*c == '/' || *c == '\\' || (*c == ':' && (c - s == 1))) { #else if (*c == '/') { #endif diff --git a/ext/standard/tests/file/basename_bug66395-win32.phpt b/ext/standard/tests/file/basename_bug66395-win32.phpt new file mode 100644 index 00000000000..a9580dc09e5 --- /dev/null +++ b/ext/standard/tests/file/basename_bug66395-win32.phpt @@ -0,0 +1,18 @@ +--TEST-- +basename bug #66395 +--SKIPIF-- + +--FILE-- + +==DONE== +--EXPECTF-- +file.txt +file.txt +file +notdriveletter:file.txt +==DONE==