Req #66914 [Opn->Csd]: basename("/path/directory/") returns directory

From: Date: Wed, 29 Jun 2016 14:45:23 +0000
Subject: Req #66914 [Opn->Csd]: basename("/path/directory/") returns directory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201909@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66914&edit=1

 ID:                 66914
 Updated by:         cmb@php.net
 Reported by:        mborchert71 at gmail dot com
 Summary:            basename("/path/directory/") returns directory
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
 Package:            *Directory/Filesystem functions
 Operating System:   Linux Debian/Ubuntu/Mint
 PHP Version:        5.4.26
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

> but thanks anyway.. this maybe closed...

Okay, closing.


Previous Comments:
------------------------------------------------------------------------
[2014-03-20 16:11:00] mborchert71 at gmail dot com

Well, yes. thanks for the enlightenment...
I won'T stand in the way of: POSIX.1-2001.
...
although if find it a bit disturbing that stringHandling with '.' and the
finalslash-basename concept...
but thanks anyway.. this maybe closed... or can i close this...
i dont know... it was my "virginity lost" in bug-reports...
;)

------------------------------------------------------------------------
[2014-03-20 08:36:28] shm@php.net

Accroding to glibc's man basename(3):

[...]
The functions dirname() and basename() break a null-terminated pathname string
into directory and filename components.  In the usual case, dirname()  returns
the string up to, but not including, the final '/', and basename() returns the
component following the final '/'.  Trailing '/' characters are not counted as
part of the pathname.
[...]

Our implementation behaves the same.

------------------------------------------------------------------------
[2014-03-16 19:10:12] mborchert71 at gmail dot com

Similar "unexpected" is, that

dirname("") returns "."

------------------------------------------------------------------------
[2014-03-16 19:01:48] mborchert71 at gmail dot com

Description:
------------
basename should return empty string on trailing slash strings

Test script:
---------------
echo basename("/test/path/");//returns path



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=66914&edit=1


Thread (5 messages)

« previous php.bugs (#201909) next »