hoaproject / Http

The Hoa\Http library.
https://hoa-project.net/
10 stars 9 forks source link

Fix double directory separator at the end of root. #4

Closed Metalaka closed 9 years ago

Metalaka commented 10 years ago

PR for https://github.com/hoaproject/Http/issues/3.

Hywan commented 10 years ago

Hello :-),

Are we sure that the resolve function will add a DS (if this is a directory)? I don't think so… maybe you could rtrim / and \, and append DS.

Metalaka commented 10 years ago

The return value of resolve is strange, or at least not fully normalized for hoa://Application*.

So if it's not normal, we must close this PR and open another into Hoa\Core to normalize resolve.

Tests

Hoa protocol (local):

$ php Hoa.php Core:resolve hoa://Application/Public
hoa://Application/Public is equivalent to:
/var/www/hoa-learn/Application/Public/
$ php Hoa.php Core:resolve hoa://Application/Public/
hoa://Application/Public/ is equivalent to:
/var/www/hoa-learn/Application/Public/
$ php Hoa.php Core:resolve hoa://Application/Public///
hoa://Application/Public/// is equivalent to:
/var/www/hoa-learn/Application/Public/

$ php Hoa.php Core:resolve hoa://Data/Bin
hoa://Data/Bin is equivalent to:
/var/www/hoa-learn/Data/Bin
$ php Hoa.php Core:resolve hoa://Data/Bin/
hoa://Data/Bin/ is equivalent to:
/var/www/hoa-learn/Data/Bin

$ php Hoa.php Core:resolve -E hoa://Application/FakeDir/
hoa://Application/FakeDir/ is equivalent to:
/var/www/hoa-learn/Application/FakeDir

Hoa protocol (global):

$ php Hoa.php Core:resolve hoa://Library/Core
hoa://Library/Core is equivalent to:
/usr/local/lib/Hoa/Core
$ php Hoa.php Core:resolve hoa://Library/Core/
hoa://Library/Core/ is equivalent to:
/usr/local/lib/Hoa/Core

File system:

$ php Hoa.php Core:resolve /var/www/hoa-learn/
/var/www/hoa-learn/ is equivalent to:
/var/www/hoa-learn/
$ php Hoa.php Core:resolve /var/www/hoa-learn
/var/www/hoa-learn is equivalent to:
/var/www/hoa-learn
Hywan commented 10 years ago

So, first, are we agree that a trailing slash must be added if this is a directory? This is for security reason.

Hywan commented 10 years ago

ping

Metalaka commented 10 years ago

If we say "must be added if this is a directory", so in a first time resolve must return a trailing slash if this is a directory?

Metalaka commented 10 years ago

/ping @Hywan

At my mind it's better to normalize resolve, maybe do that while optimizing Hoa with PHP 5.4 ?

Hywan commented 10 years ago

Yes we have to normalize this. So yes, if it is a directory, we have to add a trailing slash. This is why we do in Hoa. What is the next step?

Metalaka commented 10 years ago
Hywan commented 10 years ago

What need to be patched?

Hywan commented 10 years ago

(ahhh, I am lost with all these PR :-p).

Metalaka commented 10 years ago

resolve must return a path with a trailing DS only when it's a directory.

Metalaka commented 9 years ago

Bhoa removed in https://github.com/hoaproject/Http/commit/9dc62172506509bab8a7ef17bed2d73e32ce061b ?

Hywan commented 9 years ago

@Metalaka Yup, useless since PHP has its own build-in HTTP server.

Metalaka commented 9 years ago

Useless yes, but cool :D

Hywan commented 9 years ago

Sorry, didn't check the conflict with your PR :-(!