-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix listing and viewing filenames with non-utf8 chars
Any folder containing a least one file whose filename has characters that can be decoded to utf-8 can't be listed; additionnally these files can't be viewed. Examples: - https://sources.debian.org/src/debian-maintainers/1.52/debian-maintainers/ - https://sources.debian.org/src/cvsnt/2.5.03.2382-3.3+lenny1/ - https://sources.debian.org/src/aspell-is/0.51-0-4/ Fix this, and use the latest testdata/ commit to ensure it doesn't break again (it adds package aspell-is which contains such a file, see last example above).
- Loading branch information
1 parent
a18c72f
commit 0445961
Showing
14 changed files
with
91 additions
and
45 deletions.
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
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
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
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
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,9 @@ | ||
from debsources.url import url_decode, url_encode | ||
|
||
|
||
def test_url_encode(): | ||
assert url_encode("hello\udced") == "hello%ED" | ||
|
||
|
||
def test_url_decode(): | ||
assert url_decode("hello%ED") == "hello\udced" |
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
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,17 @@ | ||
import urllib.parse | ||
|
||
|
||
def url_encode(name: str) -> str: | ||
"""Percent-encode a surrogate-escaped string for use in URIs. | ||
E.g. hello\udced -> hello%ED | ||
""" | ||
return urllib.parse.quote(bytes(name, 'utf8', 'surrogateescape')) | ||
|
||
|
||
def url_decode(url: str) -> str: | ||
"""Percent-decode an URI with byte characters into a surrogate-escaped string. | ||
E.g. hello%ED -> hello\udced | ||
""" | ||
return urllib.parse.unquote(url, 'utf8', 'surrogateescape') |