Bug #67220 [Nab]: realpath() on MacOSX doesn't normalize the case of characters

From: Date: Wed, 07 May 2014 18:10:45 +0000
Subject: Bug #67220 [Nab]: realpath() on MacOSX doesn't normalize the case of characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185698@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67220&edit=1

 ID:                 67220
 Updated by:         tyrael@php.net
 Reported by:        nicolas dot grekas+php at gmail dot com
 Summary:            realpath() on MacOSX doesn't normalize the case of
                     characters
 Status:             Not a bug
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   MacOSX/Darwin
 PHP Version:        5.5.12
 Block user comment: N
 Private report:     N

 New Comment:

for the record HFS+ is optionally supports case sensitivity, but the current default is the case
insensitive/preserve mode AFAIK.
I don't have a windows box at hand at the moment, but I'm fairly sure that realpath on
windows does indeed correctly canonizes the path (http://www.php.net/realpath#example-2512 seems to
be confirming this).

I think closing the issue with Not a bug is wrong, we should either keep it open until we can fix
it, or mark as Won't fix, and document it.


Previous Comments:
------------------------------------------------------------------------
[2014-05-07 15:14:41] nicolas dot grekas+php at gmail dot com

The doc says "returns the canonicalized absolute pathname"

"canonicalized" is what makes this a bug.

An other example that fails is require_once:

require_once 'TEST.PHP';
require_once 'test.php';

This does require the same file twice.

------------------------------------------------------------------------
[2014-05-07 15:06:58] rasmus@php.net

Well, I am still somewhat sympathetic to this though. The native OSX realpath() call does normalize
the case. eg.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
        printf("%s
%s\n",realpath("/Users",NULL),realpath("/users",NULL));
        return(0);
}

Outputs: /Users /Users

And we used to do so as well when we relied on the system-level realpath() call. However, after we
optimized realpath() to allow us to do intra-path caching, we now use our own implementation.

Fixing this particular issue isn't that easy, and you are right, we don't promise to do
path normalization in this function.

------------------------------------------------------------------------
[2014-05-07 14:58:50] levim@php.net

Almost certainly this is because HFS+ is case-sensitive by default. Currently realpath "expands
all symbolic links and resolves references to '/./', '/../' and extra
'/' characters in the input path and returns the canonicalized absolute pathname".

Nowhere does that indicate anything about case sensitivity.

------------------------------------------------------------------------
[2014-05-06 15:24:24] nicolas dot grekas+php at gmail dot com

Description:
------------
See test script.

__FILE__, __DIR__, ReflectionClass::getFilename(), etc. are also affected (but getcwd() is OK).

Test script:
---------------
<?php

var_dump(realpath('/Users') === realpath('/users'));

Expected result:
----------------
bool(true)


Actual result:
--------------
bool(false)



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



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


Thread (11 messages)

« previous php.bugs (#185698) next »