Merge lp:~jelmer/brz/unicode-urls into lp:brz

Proposed by Jelmer Vernooij on 2018-08-19
Status: Merged
Approved by: Jelmer Vernooij on 2018-08-20
Approved revision: 7070
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/unicode-urls
Merge into: lp:brz
Diff against target: 113 lines (+37/-11)
4 files modified
breezy/bzr/remote.py (+3/-0)
breezy/bzr/smart/request.py (+2/-0)
breezy/urlutils.py (+13/-7)
python3.passing (+19/-4)
To merge this branch: bzr merge lp:~jelmer/brz/unicode-urls
Reviewer Review Type Date Requested Status
Martin Packman 2018-08-19 Approve on 2018-08-20
Review via email: mp+353372@code.launchpad.net

Commit message

Properly guard against non-ascii bytes in URLs during unescaping on Python 3.

Description of the change

Properly guard against non-ascii bytes in URLs during unescaping on Python 3.

To post a comment you must log in.
Martin Packman (gz) wrote :

Makes sense to me.

review: Approve
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/land-brz/397/

The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/land-brz/399/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bzr/remote.py'
2--- breezy/bzr/remote.py 2018-08-14 22:16:01 +0000
3+++ breezy/bzr/remote.py 2018-08-20 21:35:27 +0000
4@@ -4392,6 +4392,9 @@
5 no_context_error_translators.register(b'UnknownFormat',
6 lambda err: errors.UnknownFormatError(
7 err.error_args[0].decode('ascii'), err.error_args[0].decode('ascii')))
8+no_context_error_translators.register(b'InvalidURL',
9+ lambda err: urlutils.InvalidURL(
10+ err.error_args[0].decode('utf-8'), err.error_args[1].decode('ascii')))
11
12 def _translate_short_readv_error(err):
13 args = err.error_args
14
15=== modified file 'breezy/bzr/smart/request.py'
16--- breezy/bzr/smart/request.py 2018-06-30 23:08:49 +0000
17+++ breezy/bzr/smart/request.py 2018-08-20 21:35:27 +0000
18@@ -473,6 +473,8 @@
19 return (b'LockContention',)
20 elif isinstance(err, errors.GhostRevisionsHaveNoRevno):
21 return (b'GhostRevisionsHaveNoRevno', err.revision_id, err.ghost_revision_id)
22+ elif isinstance(err, urlutils.InvalidURL):
23+ return (b'InvalidURL', err.path.encode('utf-8'), err.extra.encode('ascii'))
24 elif isinstance(err, MemoryError):
25 # GZ 2011-02-24: Copy breezy.trace -Dmem_dump functionality here?
26 return (b'MemoryError',)
27
28=== modified file 'breezy/urlutils.py'
29--- breezy/urlutils.py 2018-08-02 01:10:26 +0000
30+++ breezy/urlutils.py 2018-08-20 21:35:27 +0000
31@@ -666,16 +666,22 @@
32
33 This returns a Unicode path from a URL
34 """
35+ # jam 20060427 URLs are supposed to be ASCII only strings
36+ # If they are passed in as unicode, unquote
37+ # will return a UNICODE string, which actually contains
38+ # utf-8 bytes. So we have to ensure that they are
39+ # plain ASCII strings, or the final .decode will
40+ # try to encode the UNICODE => ASCII, and then decode
41+ # it into utf-8.
42+
43 if PY3:
44+ if isinstance(url, text_type):
45+ try:
46+ url.encode("ascii")
47+ except UnicodeError as e:
48+ raise InvalidURL(url, 'URL was not a plain ASCII url: %s' % (e,))
49 return urlparse.unquote(url)
50 else:
51- # jam 20060427 URLs are supposed to be ASCII only strings
52- # If they are passed in as unicode, unquote
53- # will return a UNICODE string, which actually contains
54- # utf-8 bytes. So we have to ensure that they are
55- # plain ASCII strings, or the final .decode will
56- # try to encode the UNICODE => ASCII, and then decode
57- # it into utf-8.
58 if isinstance(url, text_type):
59 try:
60 url = url.encode("ascii")
61
62=== modified file 'python3.passing'
63--- python3.passing 2018-08-14 22:16:01 +0000
64+++ python3.passing 2018-08-20 21:35:27 +0000
65@@ -1,5 +1,6 @@
66 # This is the list of tests that are known to pass with Python3.
67 # "make check-nodocs3" verifies that these pass.
68+breezy.git.tests.test_builder.TestGitBranchBuilder.test_set_file_unicode
69 breezy.plugins.bash_completion.tests.test_bashcomp.BlackboxTests.test_bash_completion
70 breezy.plugins.bash_completion.tests.test_bashcomp.TestBashCodeGen.test_brz_version
71 breezy.plugins.bash_completion.tests.test_bashcomp.TestBashCodeGen.test_command_case
72@@ -9144,16 +9145,16 @@
73 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RemoteRepositoryFormat-v2)
74 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormat2a)
75 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormat2aSubtree)
76-breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-default)
77-breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-v2)
78-breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2a)
79-breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2aSubtree)
80 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5)
81 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5RichRoot)
82 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack5RichRootBroken)
83 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack6)
84 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatKnitPack6RichRoot)
85 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_ordered_no_closure(RepositoryFormatPackDevelopment2Subtree)
86+breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-default)
87+breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RemoteRepositoryFormat-v2)
88+breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2a)
89+breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormat2aSubtree)
90 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5)
91 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5RichRoot)
92 breezy.tests.per_repository_reference.test_get_record_stream.TestGetRecordStream.test_unordered_fetch_complex_split(RepositoryFormatKnitPack5RichRootBroken)
93@@ -17048,6 +17049,20 @@
94 breezy.tests.per_transport.TransportTests.test_symlink(TransportLogDecorator,LogDecoratorServer)
95 breezy.tests.per_transport.TransportTests.test_symlink(TransportTraceDecorator,TraceServer)
96 breezy.tests.per_transport.TransportTests.test_symlink(UnlistableTransportDecorator,UnlistableServer)
97+breezy.tests.per_transport.TransportTests.test_unicode_paths(ChrootTransport,TestingChrootServer)
98+breezy.tests.per_transport.TransportTests.test_unicode_paths(FakeNFSTransportDecorator,FakeNFSServer)
99+breezy.tests.per_transport.TransportTests.test_unicode_paths(FakeVFATTransportDecorator,FakeVFATServer)
100+breezy.tests.per_transport.TransportTests.test_unicode_paths(HTTPS_transport,HTTPSServer)
101+breezy.tests.per_transport.TransportTests.test_unicode_paths(HttpTransport,HttpServer)
102+breezy.tests.per_transport.TransportTests.test_unicode_paths(LocalTransport,LocalURLServer)
103+breezy.tests.per_transport.TransportTests.test_unicode_paths(MemoryTransport,MemoryServer)
104+breezy.tests.per_transport.TransportTests.test_unicode_paths(NoSmartTransportDecorator,NoSmartTransportServer)
105+breezy.tests.per_transport.TransportTests.test_unicode_paths(PathFilteringTransport,TestingPathFilteringServer)
106+breezy.tests.per_transport.TransportTests.test_unicode_paths(ReadonlyTransportDecorator,ReadonlyServer)
107+breezy.tests.per_transport.TransportTests.test_unicode_paths(RemoteTCPTransport,SmartTCPServer_for_testing)
108+breezy.tests.per_transport.TransportTests.test_unicode_paths(TransportLogDecorator,LogDecoratorServer)
109+breezy.tests.per_transport.TransportTests.test_unicode_paths(TransportTraceDecorator,TraceServer)
110+breezy.tests.per_transport.TransportTests.test_unicode_paths(UnlistableTransportDecorator,UnlistableServer)
111 breezy.tests.per_transport.TransportTests.test_win32_abspath(ChrootTransport,TestingChrootServer)
112 breezy.tests.per_transport.TransportTests.test_win32_abspath(FakeNFSTransportDecorator,FakeNFSServer)
113 breezy.tests.per_transport.TransportTests.test_win32_abspath(FakeVFATTransportDecorator,FakeVFATServer)

Subscribers

People subscribed via source and target branches