-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Prevent wrong matches in getRelativePath #16479
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
Conversation
|
The alternative would be to just detect these cases and log a warning and carry on... at least for 8.1. |
|
I wonder what could go wrong if someone ever had a real "_trashbin" folder in their home storage... |
tests/lib/files/view.php
Outdated
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.
Mind adding array('/files', '/files/', '/'), aswell?
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 tried adding more cases initially, but they failed. This is because response we are getting will sometimes have a trailing slash and sometimes not. It's a real mess and I didn't want to "enforce" the expected behavior here until we fix it and decide what the API contract is for that method, as part of #16478
I'm not sure about adding test cases that asserts that the behavior is still as buggy as it was before, basically giving a "wrong" answer.
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.
Well the case I mentioned is hardcoded before your patch:
if (rtrim($path,'/') === rtrim($this->fakeRoot, '/')) {
return '/';
}so that should always work (until someone breaks it)
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.
Ah yes, then it makes sense. I'll add it. (I'm a bit blinded by my 😡 regarding this method)
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.
also empty fakeRoot should be easily testable
|
Test coverage for the patch is good and the patch looks fine aswell.
To not break anything I'd not backport it, but only fix in master. So I agree with that. |
|
I agree, this PR should only go to 8.1 |
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.
@PVince81 Should we use strlen($root) here? That would fix:
https://github.com/owncloud/core/pull/16479/files#diff-82902132462e0bedddfef05bdebb9373R855
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'd rather not take this risk. When I tried it it changed the behavior from "having a slash in the response" to "not having a slash in the response" in some cases. Keep in mind that some code that uses this API rely insanely on such slash to exist (or not exist). There is risk of breakage.
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.
Okay, option 2 would be strlen(rtrim($this->fakeRoot, '/')) but I guess this is all 💩 until we freeze the method to one behaviour.
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.
Yeah... I'd say just leave it. I tried to keep this PR to the minimum to just avoid the bad match, nothing more.
|
Note: this PR isn't needed any more for #16475 If we want to be on the safe side, we could just defer to 8.2 |
|
@PVince81 State of this? |
|
At this point, need to continue with the proper fix on top of this PR. (too late for quickfix anyway) |
d7951e7 to
f7e6f22
Compare
|
Rebased. |
|
A new inspection was created. |
|
I did some sometests and all went good 👍 |
|
Mind also fixing getPath() ? |
|
@nickvergessen separately then. Since @icewind1991 is off then I'll have a look myself. |
|
@nickvergessen what's left to fix in getPath ? getPath uses getRelativePath and I thought this would fix it already ? |
|
I hereby 👍 the commit from @nickvergessen for the unit tests. Needs a second thumbs up for the original fix. |
|
@nickvergessen anything left to be done here ? Does it fix #18509 ? |
|
👍 |
|
@PVince81 works for the activity app atm |
Before this fix, the root "/files" with path "/files_trashbin" would return "_trashbin" as relative path...
f7e6f22 to
d26c49b
Compare
|
Rebased to wake up CI. |
|
@PVince81 OCI fails :( |
Failing OCI is unlikely to be related:
Also fixes #18509 👍 |
|
@DeepDiver1975 Merge or retrigger CI? |
…atches Prevent wrong matches in getRelativePath
Before this fix, the root "/files" with path "/files_trashbin" would
return "_trashbin" as relative path...
Please review @icewind1991 @schiesbn
I'm still having doubts whether this quickfix is safe or will break other parts of OC...
I raised #16478 to look into a more extensive fix.
Fixes #16475
Fixes #18509