All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Jansa <martin.jansa@gmail.com>
To: Phil Blundell <pb@pbcl.net>
Cc: bitbake-devel@lists.openembedded.org
Subject: Re: [RFC PATCH] bitbake: Rewrite fetch2.decodeurl() to use urlparse.urlsplit()
Date: Thu, 16 Jan 2014 15:21:39 +0100	[thread overview]
Message-ID: <20140116142139.GF3742@jama> (raw)
In-Reply-To: <1389371323.9182.169.camel@phil-desktop.brightsign>

[-- Attachment #1: Type: text/plain, Size: 3767 bytes --]

On Fri, Jan 10, 2014 at 04:28:43PM +0000, Phil Blundell wrote:
> This means that it now understands "standard" URI syntax as well as
> the slightly odd legacy bitbake variant.
> 
> There are other places in bitbake (e.g. Local.urldata_init) that also 
> need fixing, but this is a start.

I agree it's good start, I was trying to test this together with
http://lists.openembedded.org/pipermail/bitbake-devel/2014-January/004327.html

and bitbake-selftest shows failure on different URL, did it pass for you?
- ('http', 'www.google.com', '/index.html', None, None, {})
+ ('http', 'www.google.com', '/index.html', '', '', {})

+ few errors before that like:
File "/usr/lib64/python2.7/re.py", line 238, in _compile
    raise TypeError, "first argument must be string or compiled pattern"
  TypeError: first argument must be string or compiled pattern

> Signed-off-by: Phil Blundell <pb@pbcl.net>
> ---
>  lib/bb/fetch2/__init__.py | 60 ++++++++++++++++++++++++++---------------------
>  1 file changed, 33 insertions(+), 27 deletions(-)
> 
> diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
> index 260fb37..4886dae 100644
> --- a/lib/bb/fetch2/__init__.py
> +++ b/lib/bb/fetch2/__init__.py
> @@ -329,40 +329,46 @@ def decodeurl(url):
>      user, password, parameters).
>      """
>  
> -    m = re.compile('(?P<type>[^:]*)://((?P<user>.+)@)?(?P<location>[^;]+)(;(?P<parm>.*))?').match(url)
> -    if not m:
> +    if url.startswith("file://"):
> +        # This is an old-style bitbake URL.  Fix it up.
> +        url = "file:" + url[7:]
> +
> +    import urlparse
> +    d = urlparse.urlsplit(url)
> +    if not d.scheme:
>          raise MalformedUrl(url)
>  
> -    type = m.group('type')
> -    location = m.group('location')
> -    if not location:
> +    netloc = d.netloc
> +    path = d.path
> +
> +    if not path:
>          raise MalformedUrl(url)
> -    user = m.group('user')
> -    parm = m.group('parm')
>  
> -    locidx = location.find('/')
> -    if locidx != -1 and type.lower() != 'file':
> -        host = location[:locidx]
> -        path = location[locidx:]
> -    else:
> -        host = ""
> -        path = location
> -    if user:
> -        m = re.compile('(?P<user>[^:]+)(:?(?P<pswd>.*))').match(user)
> -        if m:
> -            user = m.group('user')
> -            pswd = m.group('pswd')
> -    else:
> -        user = ''
> -        pswd = ''
> +    user = ''
> +    pswd = ''
> +    host = ''
> +
> +    if netloc:
> +        m = re.compile('((?P<user>[^:@]+)(:(?P<pswd>[^@]+))?@)?(?P<host>.+)').match(netloc)
> +        if not m:
> +            raise MalformedUrl(url)
> +
> +        user = m.group('user')
> +        pswd = m.group('pswd')
> +        host = m.group('host')
>  
>      p = {}
> -    if parm:
> -        for s in parm.split(';'):
> -            s1, s2 = s.split('=')
> -            p[s1] = s2
> +    sep = path.find(";")
> +    if sep != -1:
> +        for s in path[sep+1:].split(';'):
> +            try:
> +                s1, s2 = s.split('=')
> +                p[s1] = s2
> +            except ValueError:
> +                raise MalformedUrl(url)
> +        path = path[:sep]
>  
> -    return type, host, urllib.unquote(path), user, pswd, p
> +    return d.scheme, host, urllib.unquote(path), user, pswd, p
>  
>  def encodeurl(decoded):
>      """Encodes a URL from tokens (scheme, network location, path,
> -- 
> 1.8.5
> 
> 
> 
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/bitbake-devel

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 205 bytes --]

  reply	other threads:[~2014-01-16 14:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-10 16:28 [RFC PATCH] bitbake: Rewrite fetch2.decodeurl() to use urlparse.urlsplit() Phil Blundell
2014-01-16 14:21 ` Martin Jansa [this message]
2014-01-16 14:44   ` Martin Jansa
2014-01-16 14:45 ` Olof Johansson
2014-01-17 12:33   ` Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140116142139.GF3742@jama \
    --to=martin.jansa@gmail.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=pb@pbcl.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.