
The `max_iterations` value in `#parse_curl_output` is only intended to prevent its `while` loop from potentially turning into an endless loop. This should only come into play in exceptional circumstances but the current default value (5) is low enough that we're seeing it under normal circumstances. `#parse_curl_output` isn't intended to restrict the number of redirections (this should be done using the `--max-redirs` option in `curl) but it's effectively doing this in rare cases due to the low `max_iterations` default. This is a problem because `curl` can successfully return a response only to have `#parse_curl_output` error in relation to `max_iterations`. Originally the code in `#parse_curl_output` was used in the context of livecheck, where it's not a huge issue if a check fails. However, now the `#parse_curl_output` method is used in important parts of brew like `#curl_download`. We've received a report of a download failing with the "Too many redirects (max = 5)` error, effectively preventing the user from installing a formula [from a third-party tap]. Until we can come up with a more adaptive way of bounding this `while` loop, I think we should simply raise the default to something that's less likely to be encountered under normal circumstances (e.g., 25).
Library
This directory contains all the code run by the official brew
command in Homebrew
and all formulae (package descriptions) in taps (repositories containing formulae) in Taps
subdirectories.