Merge lp:~gz/bzr-explorer/repo_view_non_ascii_branch_open_777860 into lp:bzr-explorer

Proposed by Martin Packman
Status: Merged
Approved by: Alexander Belchenko
Approved revision: 504
Merged at revision: 503
Proposed branch: lp:~gz/bzr-explorer/repo_view_non_ascii_branch_open_777860
Merge into: lp:bzr-explorer
Diff against target: 28 lines (+6/-1)
2 files modified
NEWS (+5/-0)
lib/view_repository.py (+1/-1)
To merge this branch: bzr merge lp:~gz/bzr-explorer/repo_view_non_ascii_branch_open_777860
Reviewer Review Type Date Requested Status
Alexander Belchenko Approve
Review via email: mp+60090@code.launchpad.net

Description of the change

Opening branches with non-ascii names works in general, but from the repository view you get an error about invalid urls. Seems the code is a little confused about what the path is. Both osutils and urlutils are used in the file. Simply escaping the relpath (which will always be one directory as far as I can see, so we don't need to worry about slashes) in _get_abspath appears to resolve the issue at least.

I've tested this manually, and would like to add an automated test. I don't see anything likely in the tests folder to base one off however.

To post a comment you must log in.
Revision history for this message
Alexander Belchenko (bialix) wrote :

Many thanks for your quick patch!

Re tests: testing GUI is not very easy, at least I haven't found my way into these lands yet.

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/05/2011 06:19 PM, Martin [gz] wrote:
> Martin [gz] has proposed merging lp:~gz/bzr-explorer/repo_view_non_ascii_branch_open_777860 into lp:bzr-explorer.
>
> Requested reviews:
> Bazaar Explorer Developers (bzr-explorer-dev)
> Related bugs:
> Bug #777860 in Bazaar Explorer: "InvalidURL opening branch with non-ascii characters from repository view"
> https://bugs.launchpad.net/bzr-explorer/+bug/777860
>
> For more details, see:
> https://code.launchpad.net/~gz/bzr-explorer/repo_view_non_ascii_branch_open_777860/+merge/60090
>
> Opening branches with non-ascii names works in general, but from the repository view you get an error about invalid urls. Seems the code is a little confused about what the path is. Both osutils and urlutils are used in the file. Simply escaping the relpath (which will always be one directory as far as I can see, so we don't need to worry about slashes) in _get_abspath appears to resolve the issue at least.
>
> I've tested this manually, and would like to add an automated test. I don't see anything likely in the tests folder to base one off however.

URLs passed to transports (Transport.get()) should be URLs, and not
simple paths.

bzrlib.transport.get_transport() tries to be DWIM friendly, and will try
to figure out what kind of string is passed, and whether it should be
treated as a pure URL or as a "Unicode" URL (starts with HTTP:// but
uses u'\xb5' rather than %B5, etc.)

URLs are always 7-bit ascii.

So yes, abspath() be getting an escaped relpath. I don't know whether
all the code in that file is passing in a Unicode path string or whether
it is usually/sometimes/always a URL.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3D/0EACgkQJdeBCYSNAAOzCACfYvolXU0FfhDNCsA80YT+g0RH
8yoAnixEEdhblUQ3THlqzlwqulrX2tTc
=Q1tp
-----END PGP SIGNATURE-----

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-11-26 14:42:06 +0000
3+++ NEWS 2011-05-05 16:19:28 +0000
4@@ -8,6 +8,11 @@
5 1.1.3 dd-mmm-2010
6 -----------------
7
8+Bug Fixes:
9+
10+* Rather than displaying an error saying "Invalid url supplied to transport"
11+ branches with non-ascii characters in the directory name can now be opened.
12+ (Martin [gz], #777860)
13
14 1.1.2 26-Nov-2010
15 -----------------
16
17=== modified file 'lib/view_repository.py'
18--- lib/view_repository.py 2010-02-21 05:34:30 +0000
19+++ lib/view_repository.py 2011-05-05 16:19:28 +0000
20@@ -240,7 +240,7 @@
21 return unicode(model.data(id_index).toString())
22
23 def _get_abspath(self, relpath):
24- return self._get_root_transport().abspath(relpath)
25+ return self._get_root_transport().abspath(urlutils.escape(relpath))
26
27 def do_double_clicked(self, model_index):
28 self._relpath = self._get_relpath_for_index(model_index)

Subscribers

People subscribed via source and target branches