Revert "Guard against malformed JSON parse"
This reverts commit e8535eeef8bed5c88da1d730ff430812cf6ff365.
diff --git a/.ruby-version b/.ruby-version
new file mode 100644
index 0000000..005119b
--- /dev/null
+++ b/.ruby-version
@@ -0,0 +1 @@
+2.4.1
diff --git a/tools/mboxhdr2csv.rb b/tools/mboxhdr2csv.rb
index 83dd6c0..1ebd520 100644
--- a/tools/mboxhdr2csv.rb
+++ b/tools/mboxhdr2csv.rb
@@ -156,67 +156,64 @@
# Return cached calculated data if present
cache_json = File.join(mailroot, "#{yearmonth}.json")
if File.file?(cache_json)
- begin
- return JSON.parse(File.read(cache_json))
- rescue StandardError => e
- # No-op: If we can't read the cache, fall through and attempt to recreate
- end
- end
- emails = {}
- files = Dir[File.join(mailroot, yearmonth, '*')]
- return emails if files.empty?
- emails[MAILS] = []
- emails[TOOLS] = []
- files.each do |email|
- next if email.end_with? '/index'
- message = IO.read(email.untaint, mode: 'rb')
- data = {}
- data[DATE] = DateTime.parse(message[/^Date: (.*)/, 1]).iso8601
- data[FROM] = message[/^From: (.*)/, 1]
- # Originally (before 2265343) the local method #find_who_from expected an email address and returned who, committer
- # Emulate this with the version from MailUtils which expects and updates a hash
- temp = {from: data[FROM]} # pass a hash
- MailUtils.find_who_from(temp) # update the hash
- # pick out the bits we want
- data[WHO], data[COMMITTER] = temp[:who], temp[:committer]
+ return JSON.parse(File.read(cache_json))
+ else
+ emails = {}
+ files = Dir[File.join(mailroot, yearmonth, '*')]
+ return emails if files.empty?
+ emails[MAILS] = []
+ emails[TOOLS] = []
+ files.each do |email|
+ next if email.end_with? '/index'
+ message = IO.read(email.untaint, mode: 'rb')
+ data = {}
+ data[DATE] = DateTime.parse(message[/^Date: (.*)/, 1]).iso8601
+ data[FROM] = message[/^From: (.*)/, 1]
+ # Originally (before 2265343) the local method #find_who_from expected an email address and returned who, committer
+ # Emulate this with the version from MailUtils which expects and updates a hash
+ temp = {from: data[FROM]} # pass a hash
+ MailUtils.find_who_from(temp) # update the hash
+ # pick out the bits we want
+ data[WHO], data[COMMITTER] = temp[:who], temp[:committer]
- data[SUBJECT] = message[/^Subject: (.*)/, 1]
- if nondiscuss
- nondiscuss.each do |typ, rx|
- if data[SUBJECT] =~ rx
- data[TOOLS] = typ
- break # regex.each
+ data[SUBJECT] = message[/^Subject: (.*)/, 1]
+ if nondiscuss
+ nondiscuss.each do |typ, rx|
+ if data[SUBJECT] =~ rx
+ data[TOOLS] = typ
+ break # regex.each
+ end
end
end
+ data.has_key?(TOOLS) ? emails[TOOLS] << data : emails[MAILS] << data
end
- data.has_key?(TOOLS) ? emails[TOOLS] << data : emails[MAILS] << data
- end
- # Provide as sorted data for ease of use
- emails[TOOLS].sort_by! { |email| email[DATE] }
- emails[TOOLCOUNT] = Hash.new {|h, k| h[k] = 0 }
- emails[TOOLS].each do |mail|
- emails[TOOLCOUNT][mail[TOOLS]] += 1
- end
- emails[TOOLCOUNT] = emails[TOOLCOUNT].sort_by { |k,v| -v}.to_h
-
- emails[MAILS].sort_by! { |email| email[DATE] }
- emails[MAILCOUNT] = Hash.new {|h, k| h[k] = 0 }
- emails[MAILS].each do |mail|
- emails[MAILCOUNT][mail[WHO]] += 1
- end
- emails[MAILCOUNT] = emails[MAILCOUNT].sort_by { |k,v| -v}.to_h
+ # Provide as sorted data for ease of use
+ emails[TOOLS].sort_by! { |email| email[DATE] }
+ emails[TOOLCOUNT] = Hash.new {|h, k| h[k] = 0 }
+ emails[TOOLS].each do |mail|
+ emails[TOOLCOUNT][mail[TOOLS]] += 1
+ end
+ emails[TOOLCOUNT] = emails[TOOLCOUNT].sort_by { |k,v| -v}.to_h
+
+ emails[MAILS].sort_by! { |email| email[DATE] }
+ emails[MAILCOUNT] = Hash.new {|h, k| h[k] = 0 }
+ emails[MAILS].each do |mail|
+ emails[MAILCOUNT][mail[WHO]] += 1
+ end
+ emails[MAILCOUNT] = emails[MAILCOUNT].sort_by { |k,v| -v}.to_h
- # If yearmonth is before current month, then write out yearmonth.json as cache
- if yearmonth < Date.today.strftime('%Y%m')
- begin
- File.open(cache_json, 'w') do |f|
- f.puts JSON.pretty_generate(emails)
+ # If yearmonth is before current month, then write out yearmonth.json as cache
+ if yearmonth < Date.today.strftime('%Y%m')
+ begin
+ File.open(cache_json, 'w') do |f|
+ f.puts JSON.pretty_generate(emails)
+ end
+ rescue
+ # No-op, just don't cache for now
end
- rescue
- # No-op, just don't cache for now
end
+ return emails
end
- return emails
end
end
diff --git a/tools/shane.rb b/tools/shane.rb
deleted file mode 100644
index 4430b1b..0000000
--- a/tools/shane.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env ruby
-# Utility functions Shane wrote (temporary)
-$LOAD_PATH.unshift '/srv/whimsy/lib'
-require 'whimsy/asf'
-SCANDIR = "../www"
-
-AUTHPATH = '/Users/curcuru/src/g/infrastructure-puppet/modules/subversion_server/files/authorization'
-# Use various functions
-def test()
-# auth = ASF::Authorization.initialize(file='asf', auth_path=AUTHPATH)
- # ASF::Authorization.each do |k,v|
- # puts "#{k} = #{v.join(',')}"
- # end
-end
-
-p = ASF::Person['curcuru']
-puts p.inspect
-puts p.auth
-puts "----"
-puts p.public_name
-puts "----"
-puts p.member_emails
\ No newline at end of file
diff --git a/www/401.cgi b/www/401.cgi
deleted file mode 100755
index 2021e28..0000000
--- a/www/401.cgi
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env ruby
-PAGETITLE = "401 - Unauthorized Error - Apache Whimsy"
-$LOAD_PATH.unshift '/srv/whimsy/lib'
-require 'wunderbar'
-require 'wunderbar/bootstrap'
-require 'whimsy/asf'
-
-_html do
- _body? do
- _whimsy_body(
- title: PAGETITLE,
- subtitle: "URL #{ENV['REDIRECT_URL']} Unauthorized",
- style: 'panel-danger',
- related: {
- "/" => "Whimsy Server Homepage",
- "/committers/tools" => "Whimsy All Tools Listing",
- "https://github.com/apache/whimsy/blob/master/www#{ENV['SCRIPT_NAME']}" => "See This Source Code",
- "mailto:dev@whimsical.apache.org?subject=[SITE] 401 Error Page #{ENV['REDIRECT_URL']}" => "Questions? Email Whimsy PMC"
- },
- helpblock: -> {
- _p do
- _span.label.label_danger '401'
- _ " Tsk, tsk, that's secret magician stuff. Sorry, but a good magician never reveals their tricks - you're not allowed to peek. "
- _ "You must be a member of #{ENV['Www-Authenticate']} to view this page. "
- _ "Use the same login credentials as you do for your Apache account at: "
- _a 'https://id.apache.org/', href: 'https://id.apache.org/'
- end
- }
- ) do
- # No-op
- params = _.params
- params.each do |k,v|
- _p "Param: #{k} #{v}"
- end
- _p "foo #{_.referer} "
- _p "bar #{_.content_type} "
- ENV.sort.each do |k,v|
- if k.eql? 'HTTP_AUTHORIZATION'
- # cannot use sub! because value is fozen
- # redact non-empty string
- if v and not v.empty?
- v = '<redacted>'
- end
- end
- _p "ENV: #{k} #{v}"
- end
- end
- end
-end