From 46f60fae22b420320f3616e00928d70706cf4f4c Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 3 Jan 2014 22:25:58 +0100 Subject: [PATCH] Fixed bug #66395 basename function doesn't remove drive letter --- NEWS | 1 + ext/standard/string.c | 2 +- .../tests/file/basename_bug66395-win32.phpt | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/file/basename_bug66395-win32.phpt diff --git a/NEWS b/NEWS index d842e12606d..b87803d5bf7 100644 --- a/NEWS +++ b/NEWS @@ -103,6 +103,7 @@ PHP NEWS - Standard: . Fixed bug #64760 (var_export() does not use full precision for floating-point numbers) (Yasuo) + . Fixed bug #66395 (basename function doesn't remove drive letter). (Anatol) - XMLReader: . Fixed bug #51936 (Crash with clone XMLReader). (Mike) diff --git a/ext/standard/string.c b/ext/standard/string.c index b3860ade5d8..bf2df9a6121 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1433,7 +1433,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==