14 Commits

Author SHA1 Message Date
Mike McQuaid
5e1806e796 test: rubocop-rspec style auto-corrects.
There’s too many warnings to start enabling `rubocop-rspec` by default
but let’s at least apply the cleanups it does automatically.
2018-03-25 13:30:37 +01:00
Claudia
ba830df4e6 Add tests for CurlDownloadStrategy#tarball_path
Sometimes, `brew cask fetch`/`install` fails with an error message
similar to this:

```
==> Downloading https://w3g3a5v6.ssl.hwcdn.net/upload2/game/214692/735
Error: Download failed on Cask 'steamed-hams' with message: Operation
not supported @ rb_sysopen -
/Users/claudia/Documents/dev/brew/var/homebrew/locks/steamed-hams--1.0
.com&Expires=1520937180&Signature=CGmDulxL8pmutKTlCleNTUY%2FyO9Xyl5u9y
VZUE0uWrjadjuz67Jp7zx3H7NEOhSyOhu8nzicEHRBjr3uSoOJzwkLC8LBLKnz%2B2X%2B
iq5m6IdwSVFcLp2Q1Hr2kR7ETn3rF1DIq5o0lHCyzMmyNe5giEKJNW8WF0KXriULhzLTWL
SA3ZTLCIofAdRiiGje1kNYY3C0SBqymQB8CG3ONn5kj7CIGbxrDOq5xI2ZSJdIyPysSX7S
LvEDBw2KdR24q9t1wfjS9LUzelf5TWk6ojj8p9%2FHjl%2Fi%2FVCXNN4o1mW%2FMayy2t
TY1qcC%2FTmqI1ulZS8SNuaSgr9Iys9oDF1%2BPK%2B4Sg==&hwexp=1520937440&hwsi
g=55bc66884b925ef22f8673c33bfcc33b.incomplete.lock
```

To reproduce the issue, check out this branch and run the
`cask/download_strategy` test suite:

```
brew tests --only=cask/download_strategy
```

Or take a real-life example, which would be a Cask whose URL has
**1.** no `.` character anywhere in the URL path itself (outside of
the domain name), **and 2.** at least one query parameter with a `.`
character in it; **and 3.** other query parameters following that
with a combined length of more than 255 characters.

This combination may be uncommon but it exists, especially in
[URLs that change on every visit](1002d41242/doc/cask_language_reference/stanzas/url.md (urls-that-change-on-every-visit)),
for example
[`steamed-hams`](9d7df499cd/Casks/steamed-hams.rb)
from my `claui/cask-games` tap:

    $ brew tap claui/cask-games

    $ brew cask fetch steamed-hams

In a nutshell, **URL query strings sometimes look like a very long
file extension to Homebrew,** which it then proceeds to use as a file
name.

In `CurlDownloadStrategy`, Homebrew seems to apply a heuristic to the
cask URL in order to figure out a possibly meaningful file extension.
Sometimes this heuristic produces immensely long file extensions,
especially when there’s a query parameter with a `.` character in it
but not in the URL path itself (outside of the domain name).

Homebrew then believes that everything after the `.` is a file
extension. In one of the later steps, it tries to create a lock file
containing that extension, which fails because HFS+ cannot handle
files whose base file name has more than 255 characters.

One solution would be to improve Homebrew’s extension detector a bit
so that it won’t cross individual URL query param boundaries any
longer. This is done by adding `&` as a stop character:

```
def ext
  Pathname.new(@url).extname[/[^?&]+/]
end
```

This appears to fix the issue for most (if not all) practical
purposes.
2018-03-13 16:58:52 +01:00
Markus Reiter
2cba322200 Allow curl args to be overriden. 2017-08-08 23:06:40 +02:00
Markus Reiter
ae4bafdb36 Simplify CurlDownloadStrategy. 2017-08-08 18:10:13 +02:00
Markus Reiter
b6b8e8863f Simplify SubversionDownloadStrategy. 2017-08-08 18:10:01 +02:00
ilovezfs
986887b413 Revert "Refactor SVN and cURL download strategies." 2017-08-07 14:31:56 -07:00
Markus Reiter
dc5a2c1764 Simplify CurlDownloadStrategy. 2017-08-07 21:31:17 +02:00
Markus Reiter
fb59e79689 Simplify SubversionDownloadStrategy. 2017-08-07 21:31:17 +02:00
Markus Reiter
2ad3a87045 Silence all specs by default. 2017-07-29 20:25:37 +02:00
Mike McQuaid
7a38bab333 Fixup all RuboCop warnings. 2017-05-29 18:43:18 +01:00
Markus Reiter
ed10135da4 Replace Hbc.load with CaskLoader.load. 2017-03-16 19:16:42 +01:00
Viktor Szakats
cc8f029f22 secure urls + remove -k from in-doc curl command 2017-03-14 17:27:11 +00:00
Numbermaniac
b704b48b2f Change instances of caskroom.io to caskroom.github.io 2017-03-12 23:23:22 +11:00
Markus Reiter
9fc6c7b2be Move Cask specs into brew tests. 2017-03-05 23:08:14 +01:00