summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2004-10-30 14:33:25 +0000
committerMarcus Boerger <helly@php.net>2004-10-30 14:33:25 +0000
commite2ba10a727f038b236b9eede74af8f0bf4f9ec58 (patch)
tree83447f7ad92bf10b00ea18f86b06fc395ccd8b94 /ext
parent4fd5931e704e3bb7350068c2effe24f35c195628 (diff)
downloadphp-git-e2ba10a727f038b236b9eede74af8f0bf4f9ec58.tar.gz
strip trailing (back)slash from path
Diffstat (limited to 'ext')
-rwxr-xr-xext/spl/spl_directory.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 11c09a26be..da063f7736 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -120,9 +120,14 @@ static zend_object_value spl_ce_dir_object_new(zend_class_entry *class_type TSRM
/* open a directory resource */
static void spl_ce_dir_open(spl_ce_dir_object* intern, char *path TSRMLS_DC)
{
+ int path_len = strlen(path);
intern->dirp = php_stream_opendir(path, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
- intern->path = estrdup(path);
+ if (path_len && (path[path_len-1] == '/' || path[path_len-1] == '\\')) {
+ intern->path = estrndup(path, --path_len);
+ } else {
+ intern->path = estrndup(path, path_len);
+ }
intern->index = 0;
if (intern->dirp == NULL) {