From 06155ff6e0e403b64d3912c8da8c5b17541f65d1 Mon Sep 17 00:00:00 2001 From: Valentin Kulesh Date: Sat, 16 Dec 2023 21:48:38 +0300 Subject: [PATCH] Work around recent Akamai/Microsoft issues At the moment, Microsoft Office and related casks fail audit due to failure to fetch a product homepage from the main Microsoft site (https://www.microsoft.com/) served by Akamai CDN. The failure is severe and weird: no status code is received as the connection is reset. The analysis revealed the issue is linked to `User-Agent` and `Accept-Language` headers parsing. Homebrew uses involved user agent strings and has language hardcoded as `en`. The simplest workaround is to use a simple user agent string when checking homepage availability if the cask is in an audit exceptions list. Merging this would fix Microsoft Office updates (including https://github.com/Homebrew/homebrew-cask/pull/162671) --- Library/Homebrew/cask/audit.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 025771cd27..f553544feb 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -785,8 +785,14 @@ module Cask return unless cask.homepage + user_agents = if cask.tap&.audit_exception(:simple_user_agent_for_homepage, cask.token) + ["curl"] + else + [:browser, :default] + end + validate_url_for_https_availability(cask.homepage, SharedAudits::URL_TYPE_HOMEPAGE, cask.token, cask.tap, - user_agents: [:browser, :default], + user_agents: user_agents, check_content: true, strict: strict?) end