GNU bug report logs - #24450
pypi importer outputs strange character series in optional dependency case.

Previous Next

Package: guix;

Reported by: ng0 <ng0 <at> we.make.ritual.n0.is>

Date: Fri, 16 Sep 2016 20:02:01 UTC

Severity: normal

Tags: patch

Merged with 24557, 33047, 33569, 34266

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #61 received at 24450 <at> debbugs.gnu.org (full text, mbox):

From: Ricardo Wurmus <ricardo.wurmus <at> mdc-berlin.de>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 24450 <at> debbugs.gnu.org
Subject: Re: [PATCHv2] Re: pypi importer outputs strange character series in
 optional dependency case.
Date: Mon, 27 May 2019 17:54:39 +0200
Patch number 3!

> From 0c62b541a3e8925b5ca31fe55dbe7536cf95151f Mon Sep 17 00:00:00 2001
> From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
> Date: Thu, 28 Mar 2019 00:26:01 -0400
> Subject: [PATCH 3/9] import: pypi: Improve parsing of requirement
>  specifications.
>
> The previous solution was fragile and could leave unwanted characters in a
> requirement name, such as '[' or ']'.

Wouldn’t it be sufficient to add [ and ] to the list of forbidden
characters?  The tests pass with this implementation of
clean-requirements:

(define (clean-requirements s)
 (cond
  ((string-index s (char-set #\space #\> #\= #\< #\[ #\])) => (cut string-take s <>))
  (else s)))

> +(define %requirement-name-regexp
> +  ;; Regexp to match the requirement name in a requirement specification.
> +
> +  ;; Some grammar, taken from PEP-0508 (see:
> +  ;; https://www.python.org/dev/peps/pep-0508/).
> +
> +  ;; The unified rule can be expressed as:
> +  ;; specification = wsp* ( url_req | name_req ) wsp*
> +
> +  ;; where url_req is:
> +  ;; url_req = name wsp* extras? wsp* urlspec wsp+ quoted_marker?
> +
> +  ;; and where name_req is:
> +  ;; name_req = name wsp* extras? wsp* versionspec? wsp* quoted_marker?
> +
> +  ;; Thus, we need only matching NAME, which is expressed as:
> +  ;; identifer_end = letterOrDigit | (('-' | '_' | '.' )* letterOrDigit)
> +  ;; identifier    = letterOrDigit identifier_end*
> +  ;; name          = identifier
> +  (let* ((letter-or-digit "[A-Za-z0-9]")
> +         (identifier-end (string-append "(" letter-or-digit "|"
> +                                        "[-_.]*" letter-or-digit ")"))
> +         (identifier (string-append "^" letter-or-digit identifier-end "*"))
> +         (name identifier))
> +    (make-regexp name)))

This seems a little too complicated.  Translating a grammar into a
regexp is probably not a good idea in general.  Since we don’t care
about anything other than the name it seems easier to just chop off
the string tail as soon as we find an invalid character.

-- 
Ricardo




This bug report was last modified 6 years and 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.