Skip to content

generated resource routes should allow / - #31224

Merged
butonic merged 3 commits into
masterfrom
fix-slases-in-urlparams
Jun 27, 2018
Merged

butonic merged 3 commits into
masterfrom
fix-slases-in-urlparams

Conversation

@butonic

@butonic butonic commented Apr 20, 2018 •

Copy link
Copy Markdown
Contributor

@butonic butonic self-assigned this Apr 20, 2018
@butonic butonic added this to the development milestone Apr 20, 2018
@butonic
butonic requested a review from phil-davis April 20, 2018 12:19
@butonic butonic added the p4-low Low priority label Apr 20, 2018
@butonic
butonic force-pushed the fix-slases-in-urlparams branch from c705be9 to b283ac1 Compare April 20, 2018 14:12
@codecov

codecov Bot commented Apr 20, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #31224 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #31224      +/-   ##
============================================
+ Coverage     63.41%   63.44%   +0.03%     
  Complexity    18502    18502              
============================================
  Files          1165     1165              
  Lines         69409    69410       +1     
  Branches       1264     1264              
============================================
+ Hits          44017    44039      +22     
+ Misses        25023    25002      -21     
  Partials        369      369
Flag Coverage Δ Complexity Δ
#javascript 52.58% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 64.69% <100%> (+0.03%) 18502 <0> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
lib/private/AppFramework/Routing/RouteConfig.php 95.6% <100%> (+0.04%) 30 <0> (ø) ⬇️
apps/files_trashbin/lib/Expiration.php 98.27% <0%> (+1.72%) 29% <0%> (ø) ⬇️
lib/private/Route/Router.php 65.62% <0%> (+12.5%) 54% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7cbb778...7a2c6e9. Read the comment docs.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@ownclouders rebase

@ownclouders

Copy link
Copy Markdown
Contributor

Hey! I'm GitMate.io! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost permanently ⚠️

@ownclouders

Copy link
Copy Markdown
Contributor

Automated rebase with GitMate.io was successful! 🎉

@butonic

butonic commented May 4, 2018 •

Copy link
Copy Markdown
Contributor Author

@phil-davis I think this PR supersedes

and is the proper fix for

The tests will work with these changes alone. In the real world we may need AllowEncodedSlashes On in the apache vhost config (it is not allowed in htaccess but is Offby default) This requires

  • a documentation update ... and
  • probably an admin check would make sense

@phil-davis can you test if it this PR really fixes the problem for the provisioning API?

@DeepDiver1975

Copy link
Copy Markdown
Contributor

#31017 - Handle groups with slash and percent in provisioning API

the provisioning api is not setup as a resource via appframework - ocs has it's own routing ... \o/

@phil-davis

Copy link
Copy Markdown
Contributor

This did not work for me for the Provisioning API "groups with slash in the name" cases.
See PR #31463 for my attempt.

@butonic butonic closed this May 30, 2018
@butonic
butonic deleted the fix-slases-in-urlparams branch May 30, 2018 09:08
@butonic
butonic restored the fix-slases-in-urlparams branch May 30, 2018 09:24
@butonic butonic reopened this May 30, 2018
@butonic

butonic commented May 30, 2018 •

Copy link
Copy Markdown
Contributor Author

actually, this PR solves a problem. #31463 tries to do even more (fix provisioning ap).

so we should get this in as it at least allows managing all groups from the web ui.

@PVince81 PVince81 self-assigned this Jun 19, 2018
@PVince81

Copy link
Copy Markdown
Contributor

Taking over

@PVince81

Copy link
Copy Markdown
Contributor

I have a concern: apparently you don't need to encode the slashes and it will match.

What happens if there are route conflicts ? If it happens that the id is controllable by the user, a user could manipulate the route to make it point at another similar route.

Ex:

  • route1 is "resource/{id}" (main entity)
  • route2 is "resource/{id}/sub" (collection of sub-entities)
  1. with id "test" and "resource/test/sub" it should match route2
  2. with id "test/sub" and "resource/test/sub" it should match route1 but here would match route2

Is this something we can live with ? @butonic

We could agree that route designers need to define their routes in a way that such confusion is not possible.

@ownclouders ownclouders added the p4-low Low priority label Jun 19, 2018
@PVince81

Copy link
Copy Markdown
Contributor

Second point: do we require the id to be fully encoded ?

I wrote unit tests and the matcher also matches if the slashes are not encoded, see 73acdd1#diff-3d3d328fe9bbbd7019bad6ec9ae10dacR109

I'd rather prefer to not match these to avoid the conflict mentioned above.

@PVince81

Copy link
Copy Markdown
Contributor

talked with @tomneedham and he also preferred we not touch the core router due to various risks and favor the other solution #31109

need to examine whether the latter also fixes the same issues like the former

@PVince81
PVince81 force-pushed the fix-slases-in-urlparams branch from 73acdd1 to 3626e32 Compare June 26, 2018 14:11
@PVince81

Copy link
Copy Markdown
Contributor

Changed expectation for non-encoded slash-containing params to true: the Symfony matcher automatically calls rawurldecode on parameters, so both the encoded and not encoded param will match.

The purpose of RouterTest here is to demonstrate that setting the requirement part will make it match params with slashes properly.

@PVince81

Copy link
Copy Markdown
Contributor

👍 for @butonic's code.

I need a review for the unit test extension I wrote, @butonic ?

@butonic

butonic commented Jun 26, 2018

Copy link
Copy Markdown
Contributor Author

@PVince81 nice! should we make the regex in 3626e32#diff-3d3d328fe9bbbd7019bad6ec9ae10dacR90 part of the provider params? that way we can test both: normal routes with ['id' => '[^/]+'] and resource routes with ['id' => '.+']

@PVince81

Copy link
Copy Markdown
Contributor

added test for when route disallows slashes

@butonic

butonic commented Jun 26, 2018

Copy link
Copy Markdown
Contributor Author

👍 for @PVince81 changes ... but cs wants some newlines removed

@PVince81
PVince81 force-pushed the fix-slases-in-urlparams branch from 28c5a42 to 7a2c6e9 Compare June 27, 2018 07:26
@PVince81

Copy link
Copy Markdown
Contributor

fiixed the stylzes and rebased

@butonic
butonic merged commit a49adcc into master Jun 27, 2018
@butonic
butonic deleted the fix-slases-in-urlparams branch June 27, 2018 08:52
@butonic
butonic restored the fix-slases-in-urlparams branch June 27, 2018 08:54
@tomneedham
tomneedham deleted the fix-slases-in-urlparams branch June 27, 2018 10:06
@phil-davis

Copy link
Copy Markdown
Contributor

@PVince81 @butonic now what is the workflow/timing for backporting this?
I guess we can get both pieces of this backported into stable10 - code from this PR and #31109 which is the core stable10 backport of the user_management PR owncloud-archive/user_management#20

And it will wait for after 10.0.9

@PVince81

Copy link
Copy Markdown
Contributor

yes, I'll backport this to stable10

cc @tomneedham

@PVince81

Copy link
Copy Markdown
Contributor

stable10: #31927

@lock

lock Bot commented Jul 30, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

5 participants