-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add test for . in path with no extension, fix smb #26143
Conversation
@butonic, thanks for your PR! By analyzing the annotation information on this pull request, we identified @icewind1991, @blizzz, @PVince81 and @Xenopathic to be potential reviewers |
cc @VicDeo |
backport to 9.1 needed |
@butonic don't forget to mention the other SMB master @jvillafanez |
Was about to ask about severity, seems this didn't cause any issues. Still 👍 for removing this unnecessary logic |
@@ -517,9 +512,18 @@ public function filetype($path) { | |||
public function mkdir($path) { | |||
$this->log('enter: '.__FUNCTION__."($path)"); | |||
$result = false; | |||
$path = $this->buildPath($path); | |||
$dirs = explode('/', $path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do the rest of the implementations work? Are the implementations expected to create the directories recursively?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API says it should be recursive: https://github.com/owncloud/core/blob/master/lib/public/Files/Storage/IStorage.php#L66
I tried using a recursive mkdir ... that at least also breaks webdav ... looking at the other implementations nearly none does it recursively.
will send a separate PR for that. for now I'll use 5 mkdirs ... jeez
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#7324 oh boy
We'll have to check if the mimetypes are properly sent to the clients. I think this was set to help mimetype detection. |
cdd21dd
to
5d85a8b
Compare
@jvillafanez hm:
investigating ... |
5d85a8b
to
1e7af6d
Compare
@@ -413,6 +408,7 @@ public function fopen($path, $mode) { | |||
if (!$this->isCreatable(dirname($path))) { | |||
break; | |||
} | |||
$ext = pathinfo($path, PATHINFO_EXTENSION); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My trust level in these kind of functions is usually low. I've checked http://php.net/manual/en/function.pathinfo.php and I'm not sure if this is what we really want here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pathinfo actually implements the extension extraction correctly. In contrast to the php mess used before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may need additional handling because we have different mimetypes for .tar.bz2/.bz2 and .tar.gz/.gz, see
"tar.bz2": ["application/x-bzip2"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the basename of the path starts with a dot, the following characters are interpreted as extension, and the filename is empty
This is what worries me, in addition to the .tar.bz2 problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a test for '/path/to a/hidden/.file', '/path/to a/hidden/.file.php', '/path/to a/hidden/.file.gz' and '/path/to a/hidden/.file.tar.gz' to https://github.com/owncloud/core/pull/26143/files#diff-5513e31c79d843ab51b3af2a528af6ddR138
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jvillafanez pathinfo treats .files correctly:
pathinfo('.hidden')
Array
(
[dirname] => .
[basename] => .hidden
[extension] => hidden
[filename] =>
)
pathinfo('.hidden.gz')
Array
(
[dirname] => .
[basename] => .hidden.gz
[extension] => gz
[filename] => .hidden
)
perfectly fine IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I the only one who think that for the ".hidden" file the filename should be ".hidden" and the extension should be empty? If I'm the only one, then let's move on.
@PVince81 @VicDeo @jvillafanez jenkins is green.
|
2e021f8
to
d59b6af
Compare
* @return array|string|null | ||
* @since 9.2.0 | ||
*/ | ||
static function pathinfo( $path, $options = PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to simplify this code? Scrutinizer reports a complexity value of 17 for this function, which is pretty high: https://scrutinizer-ci.com/g/owncloud/core/inspections/a866f5ac-174c-4d40-af68-2a73fc3059f1/code-structure/class/OCP%5CFiles
At least we have tests for this function, but this is a black box for me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you simplify this? Maybe:
if ($path endswith 'tar.gz') {
$result = handleTarGzPaths($path);
} else if ($path endswith 'tar.bz2') {
$result = handleTarBz2Paths($path)
} else {
$result = pathinfo($path);
}
Whether those "handle" function are public or private is just to be decided, but at least the complexity of this function is reduced and it should also be easier to extend with other custom extensions such as ".tar.gzip", ".jra.gz" or ".hbm.xml" which we might want to add at some point.
Maybe we should consider to introduce a "ExtensionHandling" class or similar for these kind of functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I absolutly agree on moving this to a class on its own - we don't want static APIs in OCP and ocp files shall die.
e9968f7
to
7d11107
Compare
7d11107
to
7599680
Compare
@jvillafanez @PVince81 @PhilippSchaffrath jenkins is green after a rebase again |
@jvillafanez @DeepDiver1975 rereview ? Not sure if your points were addressed though. |
Except for my comment, the rest of the code is fine. |
finish this or defer ? |
I'm not sure if we have tested with different locales (http://php.net/manual/es/function.pathinfo.php#119468). If not I'd rather defer this. Code should be fine otherwise. |
Any update on this? |
I'd wait for @butonic status report on this. |
any update ? |
@jvillafanez @butonic please evaluate if investing time in this provides enough value I'd vote for closing unless there are strong arguments for keeping this |
we should probably move the test cases to an acceptance test that we can also use with phoenix and OCIS |
If we want to keep this I'd prefer to make a new PR based on this one. This way we don't need to deal with the conflicts.
In any case, fixing all those conflicts will be a pain, so I don't think it's a good idea. |
raised #34442 for acceptance test cases |
I can't find the original comment/reason for this PR as the link in OP doesn't work. If this was important, please re-raise as new ticket. |
Description
Related Issue
#25994 (comment)
Motivation and Context
removes unnecessary code which might lead to problems
How Has This Been Tested?
new unit test
Screenshots (if appropriate):
Types of changes
Checklist: