Skip to content

Commit

Permalink
Added a 'undecoded_url' variable to addon providers.
Browse files Browse the repository at this point in the history
Currently, a URL can get encoded and decoded many times. This can cause the original name of a file to be near impossible to figure out if it uses special characters. This variable will help solve this problem.
  • Loading branch information
AddisonSchiller committed Sep 11, 2017
1 parent 879aedd commit a8717a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions waterbutler/core/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def __init__(self, auth: dict,
self.auth = auth
self.credentials = credentials
self.settings = settings
self.undecoded_path = None

self.provider_metrics = MetricsRecord('provider')
self.provider_metrics.add('auth', auth)
Expand Down
11 changes: 10 additions & 1 deletion waterbutler/server/api/v1/provider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,17 @@ async def prepare(self, *args, **kwargs):

self.auth = await auth_handler.get(self.resource, provider, self.request)
self.provider = utils.make_provider(provider, self.auth['auth'], self.auth['credentials'], self.auth['settings'])
self.path = await self.provider.validate_v1_path(self.path, **self.arguments)

# Find start of provider name, and start of ? marker and pull out file name from between them.
provider_index = self.request.uri.index(self.path_kwargs['provider'] + '/')
provider_length = (len(self.path_kwargs['provider']))
end_of_path_index = self.request.uri.find('?')
# If there is no ? in uri, go to end of uri
if end_of_path_index == -1:
end_of_path_index = len(self.request.uri)

self.provider.undecoded_path = self.request.uri[provider_index + provider_length: end_of_path_index]
self.path = await self.provider.validate_v1_path(self.path, **self.arguments)
self.target_path = None

# post-validator methods perform validations that expect that the path given in the url has
Expand Down

0 comments on commit a8717a5

Please sign in to comment.