Repository: spack/spack

Issue:
Spack cannot parse URLs with '?' characters
```bash
$ spack create -n sionlib http://apps.fz-juelich.de/jsc/sionlib/download.php?version=1.7.1
==> Error: Couldn't detect version in: http://apps.fz-juelich.de/jsc/sionlib/download.php?version=1.7.1
```
Removing '?' allows it to parse the version number and fail in the expected way when it cannot fetch the URL
``` bash
$ spack create -n sionlib http://apps.fz-juelich.de/jsc/sionlib/download.phpversion=1.7.1
==> This looks like a URL for sionlib version 1.7.1
==> Creating template for package sionlib
==> Downloading...
==> Fetching http://apps.fz-juelich.de/jsc/sionlib/download.phpversion=1.7.1

curl: (22) The requested URL returned error: 404 Not Found
==> Fetching from http://apps.fz-juelich.de/jsc/sionlib/download.phpversion=1.7.1 failed.
==> Something failed on http://apps.fz-juelich.de/jsc/sionlib/download.phpversion=1.7.1, skipping.
    (All fetchers failed for spack-stage-28H9l9)
==> Error: Could not fetch any tarballs for sionlib
```


Discussion:
This problem isn't restricted to `spack create`. If you run:
```
$ spack url-parse http://apps.fz-juelich.de/jsc/sionlib/download.php?version=1.7.1
==> Error: Couldn't detect version in: http://apps.fz-juelich.de/jsc/sionlib/download.php?version=1.7.1
```
you'll see the same problem. Once #2707 is merged, you'll at least be able to say:
```
$ spack create -n sionlib
```
and fill in the rest of the details yourself.
If you actually wanted to try to fix it, you would want to add a regex to `parse_version_offset` in `lib/spack/spack/url.py` like was done in #2640 and #2677.

Resolving patch:
diff --git a/lib/spack/spack/url.py b/lib/spack/spack/url.py
--- a/lib/spack/spack/url.py
+++ b/lib/spack/spack/url.py
@@ -213,7 +213,9 @@ def parse_version_offset(path, debug=False):
         # Search dotted versions:
         #   e.g., https://gitlab.kitware.com/vtk/vtk/repository/archive.tar.bz2?ref=v7.0.0
         #   e.g., https://example.com/org/repo/repository/archive.tar.bz2?ref=SomePrefix-2.1.1
+        #   e.g., http://apps.fz-juelich.de/jsc/sionlib/download.php?version=1.7.1
         (r'\?ref=(?:.*-|v)*((\d+\.)+\d+).*$', suffix),
+        (r'\?version=((\d+\.)+\d+)', suffix),
 
         # e.g. boost_1_39_0
         (r'((\d+_)+\d+)$', stem),
@@ -304,6 +306,7 @@ def parse_name_offset(path, v=None, debug=False):
         (r'/([^/]+)[_.-](bin|dist|stable|src|sources)[_.-]%s' % v, path),
         (r'github.com/[^/]+/([^/]+)/archive', path),
         (r'[^/]+/([^/]+)/repository/archive', path),  # gitlab
+        (r'([^/]+)/download.php', path),
 
         (r'([^/]+)[_.-]v?%s' % v, stem),   # prefer the stem
         (r'([^/]+)%s' % v, stem),


Test patch:
diff --git a/lib/spack/spack/test/url_parse.py b/lib/spack/spack/test/url_parse.py
--- a/lib/spack/spack/test/url_parse.py
+++ b/lib/spack/spack/test/url_parse.py
@@ -364,3 +364,8 @@ def test_luaposix_version(self):
         self.check(
             'luaposix', '33.4.0',
             'https://github.com/luaposix/luaposix/archive/release-v33.4.0.tar.gz')
+
+    def test_sionlib_version(self):
+        self.check(
+            'sionlib', '1.7.1',
+            'http://apps.fz-juelich.de/jsc/sionlib/download.php?version=1.7.1')