Skip to content
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

don't go into an infinite loop when CONTENT_PATH_PREFIX is followed by / #763

Merged
merged 1 commit into from Jul 27, 2020

Conversation

SimonPe
Copy link
Contributor

@SimonPe SimonPe commented Jun 27, 2020

this would cause path to start with a /
and because

>>> os.path.split('/path')
('/', 'path')
>>> os.path.split('/')
('/', '')

base would never end up as None but stay as / resulting in an infinite loop.

Please be sure you have read our documentation on creating PRs:
https://docs.pulpproject.org/contributing/pull-request-walkthrough.html

@pulpbot
Copy link
Member

pulpbot commented Jun 27, 2020

WARNING!!! This PR is not attached to an issue. In most cases this is not advisable. Please see our PR docs for more information about how to attach this PR to an issue.

@daviddavis
Copy link
Contributor

Thank you for the contribution! In order to move this forward, we'd need to file an issue. Would you mind doing so: https://pulp.plan.io/projects/pulp/issues/new ? Also, I'm not sure if I fully understand the reproducer so if you could include some steps to reproduce this, that'd be great.

@SimonPe
Copy link
Contributor Author

SimonPe commented Jun 30, 2020

@@ -151,7 +151,7 @@ def _base_paths(path):
tree = []
while True:
base = os.path.split(path)[0]
if not base:
if not base or base == '/':
Copy link
Member

Choose a reason for hiding this comment

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

@daviddavis in the example given this would match in both cases, so I was thinking this would break in too many cases. I didn't run it though, maybe in running it it makes sense?

Copy link
Member

Choose a reason for hiding this comment

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

On chat @daviddavis explained that the example isn't indicative of the problem like /pulp/content// is. With an example like /pulp/content// I can see how this is solving the problem.

@daviddavis
Copy link
Contributor

This works for me. Originally, the content app hangs and now it returns 404 when I hit /pulp/content//.

However, the problem is not fully fixed. /pulp/content/// still hangs:

>>> os.path.split('//')
('//', '')

I think we need to check for 1 to N number of slashes.

@SimonPe
Copy link
Contributor Author

SimonPe commented Jul 8, 2020

@daviddavis thanks for catching that, and thanks to that catch I realised we can just do .lstrip('/')

commit amended to do so.

@daviddavis
Copy link
Contributor

Awesome, thanks. This looks good to me.

In order to get the CI passing, you have to add "fixes #7066" to your commit message and a changelog entry (CHANGES/7066.bugfix).

@bmbouter
Copy link
Member

bmbouter commented Jul 8, 2020

This revision looks good to me.

@daviddavis
Copy link
Contributor

Hey @SimonPe. We'd love to get this merged. Do you think you could address the changelog and commit message changes?

… by `/`

this would cause `path` to start with a `/`
and because
```
>>> os.path.split('/path')
('/', 'path')
>>> os.path.split('/')
('/', '')
```
`base` would never end up as `None` but stay as `/` resulting in an infinite loop.

fixes #7066
@SimonPe
Copy link
Contributor Author

SimonPe commented Jul 25, 2020

sorry, was a bit busy with other priorities the last couple of weeks, should be fine now.

@SimonPe SimonPe requested a review from bmbouter July 27, 2020 07:05
Copy link
Member

@mdellweg mdellweg left a comment

Choose a reason for hiding this comment

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

Thank you!

@daviddavis daviddavis merged commit 2449884 into pulp:master Jul 27, 2020
@pulpbot pulpbot mentioned this pull request Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants