Skip to content
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

Fix sync_uri parsing for paths beginning with file:// #28

Closed
wants to merge 1 commit into from
Closed

Fix sync_uri parsing for paths beginning with file:// #28

wants to merge 1 commit into from

Conversation

Coacher
Copy link
Contributor

@Coacher Coacher commented May 25, 2016

Portage allows file URLs, i.e. paths beginning with 'file://',
in sync_uri. According to RFC-1738 1 a file URL must take the form
'file:///foo/bar' or 'file:///foo/bar', when 'host' is omitted
(in this case localhost is assumed).

Portage incorrectly parses file URLs because it leaves the second slash
from the 'file://' prefix as a part of the URL. Additionally test suite
incorrectly uses file URLs beginning with 'file:/' instead of 'file://'.

This patch adjusts string offset so that file URLs are parsed correctly:

sync_uri='/foo/bar/baz'
('file://' + sync_uri)[6:]
'//foo/bar/baz'
('file://' + sync_uri)[6:] == sync_uri
False
('file://' + sync_uri)[7:]
'/foo/bar/baz'
('file://' + sync_uri)[7:] == sync_uri
True

Additionally test suite is updated to use file URLs of the form
'file:///foo/bar' as required by the aforementioned RFC.

@mgorny
Copy link
Member

mgorny commented May 25, 2016

@gentoo/portage, wouldn't it be better to actually use urllib.parse (urlparse) facilities rather than hand parsing and offsets?

@Coacher
Copy link
Contributor Author

Coacher commented May 27, 2016

I don't know if gentoo-portage-dev ML is premoderated, but I've sent this patch to ML a couple of days ago and I still cannot see it in the archive. Is there smth else I should do to get this moving forward?

@dol-sen
Copy link
Contributor

dol-sen commented May 27, 2016

You need to be subscribed to the mail list or it will be rejected. So if you have multiple email id's/accounts, you need to make sure you send it from the correct id/email account.

But I initially agree with mgorny that it is likely better to use urllib to parse the uri than hand parsing and offsets. What are the dis-advantages/cons to using that lib?

@Coacher
Copy link
Contributor Author

Coacher commented May 28, 2016

I see. Thank you for the info. Should I post this patch to ML then or here is enough?

@dol-sen
Copy link
Contributor

dol-sen commented May 28, 2016

The mail list is preffered, but here can work also, it just sometimes takes longer for us to get around to it/notice it.

Portage allows file URLs, i.e. paths beginning with 'file://',
in sync_uri. According to RFC-1738 [1] a file URL must take the form
'file://<host>/foo/bar' or 'file:///foo/bar', when <host> is omitted
(in this case localhost is assumed).

Portage incorrectly parses file URLs because it leaves the second slash
from the 'file://' prefix as a part of the URL. Additionally test suite
incorrectly uses file URLs beginning with 'file:/' instead of 'file://'.

This patch adjusts string offset so that file URLs are parsed correctly:

>>> sync_uri='/foo/bar/baz'
>>> ('file://' + sync_uri)[6:]
'//foo/bar/baz'
>>> ('file://' + sync_uri)[6:] == sync_uri
False
>>> ('file://' + sync_uri)[7:]
'/foo/bar/baz'
>>> ('file://' + sync_uri)[7:] == sync_uri
True

Additionally test suite is updated to use file URLs of the form
'file:///foo/bar' as required by the aforementioned RFC.

[1]: https://tools.ietf.org/html/rfc1738#section-3.10
@Coacher
Copy link
Contributor Author

Coacher commented Feb 1, 2017

Rebased and repushed to fix merge conflict.

@zmedico
Copy link
Member

zmedico commented Jul 2, 2017

Why not use urlparse, like mgorny suggested?

@dol-sen
Copy link
Contributor

dol-sen commented Jul 2, 2017

Sorry, we've been so caught up with things, we've neglected the PR's in here...

Is there any chance you can rebase the patch on urlparse?

@Coacher
Copy link
Contributor Author

Coacher commented Jul 2, 2017

Is there any chance you can rebase the patch on urlparse?

I'm not interested.

@Coacher Coacher deleted the fix-sync_uri-parsing-for-local-repositories branch November 23, 2017 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants