Skip to content

Refactor webroot detection in resource locator#6332

Merged
MorrisJobke merged 1 commit into
nextcloud:masterfrom
lukanetconsult:hotfix/6028-realpath-on-webroot
Sep 6, 2017
Merged

Refactor webroot detection in resource locator#6332
MorrisJobke merged 1 commit into
nextcloud:masterfrom
lukanetconsult:hotfix/6028-realpath-on-webroot

Conversation

@tux-rampage

Copy link
Copy Markdown
Contributor

The current implementation breaks installations with symlinks to
directories inside the webroot (i.E. apps).

With this change both variants, directory and symlinks) will be detected
correctly.

Fixes: #6028

@mention-bot

Copy link
Copy Markdown

@tux-rampage, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nickvergessen, @bartv2 and @skjnldsv to be potential reviewers.

@MorrisJobke

Copy link
Copy Markdown
Member

One positive feedback already: #6028 (comment)

* @param string $root
* @return string|null The web root or null on failure
*/
protected function findWebRoot($root)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put it on the end of the line before this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you men? Putting the method to the bottom of the class?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He means the bracket on the end of line :)


if (!$webRoot) {
$realpath = realpath($root);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use !==

@MorrisJobke MorrisJobke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code change makes sense and still works 👍

@MorrisJobke

Copy link
Copy Markdown
Member

Code change makes sense and still works 👍

Comments from above still apply of course 😉

@tux-rampage

Copy link
Copy Markdown
Contributor Author

Do you want me to push a squashed commit, or will it be OK to simply push the requested changes?

@MorrisJobke

Copy link
Copy Markdown
Member

Do you want me to push a squashed commit, or will it be OK to simply push the requested changes?

Squashed would be awesome :)

@MorrisJobke MorrisJobke added this to the Nextcloud 13 milestone Sep 6, 2017
The current implementation breaks installations with symlinks to
directories inside the webroot (i.E. apps).

With this change both variants, directory and symlinks, will be detected
correctly.

Fixes: nextcloud#6028
Signed-off-by: Axel Helmert <axel.helmert@luka.de>
@tux-rampage tux-rampage force-pushed the hotfix/6028-realpath-on-webroot branch from 7a52341 to 7a33b92 Compare September 6, 2017 19:34
@codecov

codecov Bot commented Sep 6, 2017

Copy link
Copy Markdown

Codecov Report

Merging #6332 into master will decrease coverage by 22.76%.
The diff coverage is 31.42%.

@@              Coverage Diff              @@
##             master    #6332       +/-   ##
=============================================
- Coverage     53.32%   30.55%   -22.77%     
+ Complexity    22509    22500        -9     
=============================================
  Files          1407     1403        -4     
  Lines         87149    87080       -69     
  Branches       1329     1327        -2     
=============================================
- Hits          46471    26608    -19863     
- Misses        40678    60472    +19794
Impacted Files Coverage Δ Complexity Δ
lib/private/Template/CSSResourceLocator.php 0% <0%> (ø) 25 <0> (-2) ⬇️
lib/private/Template/ResourceLocator.php 67.74% <44%> (+2.92%) 25 <7> (+5) ⬆️
apps/files_versions/lib/AppInfo/Application.php 0% <0%> (-100%) 2% <0%> (ø)
apps/files_sharing/lib/External/MountProvider.php 0% <0%> (-100%) 4% <0%> (ø)
lib/private/TagManager.php 0% <0%> (-100%) 4% <0%> (ø)
apps/files_versions/lib/Command/Expire.php 0% <0%> (-100%) 3% <0%> (ø)
lib/private/SystemTag/ManagerFactory.php 0% <0%> (-100%) 3% <0%> (ø)
lib/private/DB/QueryBuilder/QueryFunction.php 0% <0%> (-100%) 2% <0%> (ø)
lib/private/Files/Mount/CacheMountProvider.php 0% <0%> (-100%) 4% <0%> (ø)
apps/user_ldap/lib/BackendUtility.php 0% <0%> (-100%) 1% <0%> (ø)
... and 398 more

@tux-rampage

Copy link
Copy Markdown
Contributor Author

Added style fixes as requested - squashed commit

@skjnldsv skjnldsv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Sep 6, 2017
@MorrisJobke MorrisJobke merged commit d84a20e into nextcloud:master Sep 6, 2017
parent::append($root, $file, $webRoot, $throw);
} else {
if (!$webRoot) {
$tmpRoot = realpath($root);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removed var is still used in line 134 which results in error msgs: Undefined variable: tmpRoot

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, I ashamed to have missed that! 🙈

@tux-rampage

Copy link
Copy Markdown
Contributor Author

True, should I add another PR?

@skjnldsv

skjnldsv commented Sep 7, 2017

Copy link
Copy Markdown
Member

@tux-rampage yes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to release Ready to be released and/or waiting for tests to finish feature: scss technical debt 🧱 🤔🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants