-
Notifications
You must be signed in to change notification settings - Fork 4
verify_url Hotfix
#20
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
Changes from all commits
0152662
a0a9004
79f32d4
a07428b
42d2a7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
| from functools import wraps | ||
| from typing import Tuple | ||
| from urllib.parse import urljoin | ||
| import re | ||
| import os | ||
|
|
||
| import jsondiff as jd | ||
| import requests | ||
|
|
@@ -251,8 +253,20 @@ def _construct_remote_url(self) -> str: | |
| Returns: | ||
| str: The URL of the remote server. | ||
| """ | ||
| verify_url_regex = re.compile(r"([12]\d\d\d[A-Za-z&\.]{5}[A-Za-z0-9\.]{9}[A-Z\.]/verify_url\:)(http[s]?\://)(.*)") | ||
|
|
||
| path = request.full_path.replace(self._deploy_path, "", 1) | ||
| path = path[1:] if path.startswith("/") else path | ||
| #This block exists because of an incompatibility between urlparse.urljoin and urllib.parse.urljoin | ||
| #This incompatibility results in http(s):// -> http(s):/ if the proc spec occurs in the middle of the url. | ||
| try: | ||
| resolver_check = verify_url_regex.match(path) | ||
| if resolver_check: | ||
| resolver_groups = resolver_check.groups() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure this will only ever return one item in the tuple, since there's only one capturing group in your regex
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah... not sure what happened but an older version of the regex was pushed with the newer normalizing code. Should be fixed now. |
||
| return str(self._remote_base_url) + "/" + os.path.normpath(resolver_groups[0]) \ | ||
| + resolver_groups[1] + os.path.normpath(resolver_groups[2]) | ||
| except ValueError: | ||
| current_app.logger.exception("Failed to properly check url path for resolver verify_url path.") | ||
| return urljoin(self._remote_base_url, path) | ||
|
|
||
|
|
||
|
|
||
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.
Will the bibcode+
verify_url:https://path...always be at the beginning of the path?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.
For the particular issue we are handling, yes. We will need to adapt this when we move away from bibcodes, but I would hope it would just be mimicking the fix in
resolver-gateway