From 6720f8bd1e0237a44bbc0f53769a9d232fb19d62 Mon Sep 17 00:00:00 2001 From: hyuraku <32809703+hyuraku@users.noreply.github.com> Date: Mon, 17 May 2021 23:52:55 +0900 Subject: [PATCH 1/4] repair pub-date in livecheck --- Library/Homebrew/livecheck/strategy/sparkle.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index efff18965e..5ba6abc26f 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -75,7 +75,7 @@ module Homebrew version ||= (item > "version").first&.text&.strip title = (item > "title").first&.text&.strip - pub_date = (item > "pubDate").first&.text&.strip&.yield_self { |d| Time.parse(d) } + pub_date = (item > "pubDate").first&.text&.strip&.yield_self { |d| Time.parse(d) } || Time.new(0) if (match = title&.match(/(\d+(?:\.\d+)*)\s*(\([^)]+\))?\Z/)) short_version ||= match[1] From e7d3b2cb3116cdd5354c443b0534e50b26ce6113 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Tue, 22 Jun 2021 00:14:07 -0400 Subject: [PATCH 2/4] Sparkle: Move default pub_date value --- Library/Homebrew/livecheck/strategy/sparkle.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index 5ba6abc26f..38c2809188 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -75,7 +75,7 @@ module Homebrew version ||= (item > "version").first&.text&.strip title = (item > "title").first&.text&.strip - pub_date = (item > "pubDate").first&.text&.strip&.yield_self { |d| Time.parse(d) } || Time.new(0) + pub_date = (item > "pubDate").first&.text&.strip&.yield_self { |d| Time.parse(d) } if (match = title&.match(/(\d+(?:\.\d+)*)\s*(\([^)]+\))?\Z/)) short_version ||= match[1] @@ -88,7 +88,7 @@ module Homebrew data = { title: title, - pub_date: pub_date, + pub_date: pub_date || Time.new(0), url: url, bundle_version: bundle_version, }.compact From a5768de0c3789dd771b3f6d5b74ae4171cb26f03 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Tue, 22 Jun 2021 09:23:56 -0400 Subject: [PATCH 3/4] Sparkle: Account for empty pubDate --- Library/Homebrew/livecheck/strategy/sparkle.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index 38c2809188..34cfe28934 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -75,7 +75,7 @@ module Homebrew version ||= (item > "version").first&.text&.strip title = (item > "title").first&.text&.strip - pub_date = (item > "pubDate").first&.text&.strip&.yield_self { |d| Time.parse(d) } + pub_date = (item > "pubDate").first&.text&.strip&.presence&.yield_self { |d| Time.parse(d) } if (match = title&.match(/(\d+(?:\.\d+)*)\s*(\([^)]+\))?\Z/)) short_version ||= match[1] From 23f8cb9f4acc83949037ce8f6c95067e9cc49629 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Tue, 22 Jun 2021 09:55:22 -0400 Subject: [PATCH 4/4] Sparkle: Handle ArgumentError from Time#parse --- Library/Homebrew/livecheck/strategy/sparkle.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/livecheck/strategy/sparkle.rb b/Library/Homebrew/livecheck/strategy/sparkle.rb index 34cfe28934..c1ddbff67d 100644 --- a/Library/Homebrew/livecheck/strategy/sparkle.rb +++ b/Library/Homebrew/livecheck/strategy/sparkle.rb @@ -75,7 +75,12 @@ module Homebrew version ||= (item > "version").first&.text&.strip title = (item > "title").first&.text&.strip - pub_date = (item > "pubDate").first&.text&.strip&.presence&.yield_self { |d| Time.parse(d) } + pub_date = (item > "pubDate").first&.text&.strip&.presence&.yield_self do |date_string| + Time.parse(date_string) + rescue ArgumentError + # Omit unparseable strings (e.g. non-English dates) + nil + end if (match = title&.match(/(\d+(?:\.\d+)*)\s*(\([^)]+\))?\Z/)) short_version ||= match[1]