-
Notifications
You must be signed in to change notification settings - Fork 94
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
review: small fixes #6541
Open
oliver-sanders
wants to merge
4
commits into
cylc:7.8.x
Choose a base branch
from
oliver-sanders:cylc-review++
base: 7.8.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
review: small fixes #6541
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c4f5f8b
review: handle UTF-8 characters in log files
oliver-sanders b708330
review: handle workflow IDs with non-ASCII characters.
oliver-sanders e4da0b6
review: restrict symlink scope
oliver-sanders 2e7919a
Apply suggestions from code review
oliver-sanders File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# This code is derived from the cPython "urllib" module and retains its | ||
# original license. | ||
# | ||
# Python software and documentation are licensed under the | ||
# Python Software Foundation License Version 2. | ||
|
||
always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||
'abcdefghijklmnopqrstuvwxyz' | ||
'0123456789' '_.-') | ||
_safe_map = {} | ||
for i, c in zip(xrange(256), str(bytearray(xrange(256)))): | ||
_safe_map[c] = c if (i < 128 and c in always_safe) else '%{:02X}'.format(i) | ||
_safe_quoters = {} | ||
|
||
def quote(s, safe='/'): | ||
"""quote('abc def') -> 'abc%20def' | ||
|
||
Each part of a URL, e.g. the path info, the query, etc., has a | ||
different set of reserved characters that must be quoted. | ||
|
||
RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists | ||
the following reserved characters. | ||
|
||
reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | | ||
"$" | "," | ||
|
||
Each of these characters is reserved in some component of a URL, | ||
but not necessarily in all of them. | ||
|
||
By default, the quote function is intended for quoting the path | ||
section of a URL. Thus, it will not encode '/'. This character | ||
is reserved, but in typical usage the quote function is being | ||
called on a path where the existing slash characters are used as | ||
reserved characters. | ||
""" | ||
# fastpath | ||
if not s: | ||
if s is None: | ||
raise TypeError('None object cannot be quoted') | ||
return s | ||
cachekey = (safe, always_safe) | ||
try: | ||
(quoter, safe) = _safe_quoters[cachekey] | ||
except KeyError: | ||
safe_map = _safe_map.copy() | ||
safe_map.update([(c, c) for c in safe]) | ||
quoter = safe_map.get | ||
oliver-sanders marked this conversation as resolved.
Show resolved
Hide resolved
|
||
safe = always_safe + safe | ||
_safe_quoters[cachekey] = (quoter, safe) | ||
if not s.rstrip(safe): | ||
return s | ||
return ''.join([quoter(c, c) for c in s]) | ||
oliver-sanders marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@dpmatthews, can you ok this.
Sadly I couldn't achieve the required changes via hot patching.
The original code can be found here (2.7) https://github.com/python/cpython/blob/8d21aa21f2cbc6d50aab3f420bb23be1d081dac4/Lib/urllib.py#L1269
And the license here: https://github.com/python/cpython/blob/v2.7.18/LICENSE#L62