This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 7300b3f  untaint and tidyup
7300b3f is described below

commit 7300b3fcdbdcd3a21cc10871ce7d97e8167002f5
Author: Sebb <[email protected]>
AuthorDate: Tue Sep 29 23:33:05 2020 +0100

    untaint and tidyup
---
 lib/whimsy/asf/mail.rb | 54 +++++++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/lib/whimsy/asf/mail.rb b/lib/whimsy/asf/mail.rb
index f2836b1..402fc5d 100644
--- a/lib/whimsy/asf/mail.rb
+++ b/lib/whimsy/asf/mail.rb
@@ -16,7 +16,7 @@ module ASF
       # load info from LDAP
       people = ASF::Person.preload(['mail', 'asf-altEmail'])
       people.each do |person|
-        (person.mail+person.alt_email).each do |mail|
+        (person.mail + person.alt_email).each do |mail|
           list[mail.downcase] = person
         end
       end
@@ -33,6 +33,7 @@ module ASF
         person = Person.find(icla.id)
         list[icla.email.downcase] ||= person
         next if icla.noId?
+
         list["#{icla.id.downcase}@apache.org"] ||= person
       end
 
@@ -92,7 +93,7 @@ module ASF
 
     def self.members_allowed
       self._load_auto()
-      @auto[:members]+@auto[:chairs]
+      @auto[:members] + @auto[:chairs]
     end
 
     # which lists are available for subscription via Whimsy?
@@ -103,9 +104,10 @@ module ASF
     # output is and array of entries: lid or [dom,list,lid]
     def self.cansub(member, pmc_chair, ldap_pmcs, lidonly = true)
       allowed = []
-      parse_flags do |dom,list,f|
-        lid = archivelistid(dom,list)
+      parse_flags do |dom, list, f|
+        lid = archivelistid(dom, list)
         next if self.cannot_sub.include? lid # probably unnecessary
+
         cansub = false
         modsub = isModSub?(f)
         if not modsub # subs not moderated; allow all
@@ -117,10 +119,8 @@ module ASF
             if list == 'private' or self.members_allowed.include?(lid)
               cansub = true
             end
-          else
-            if ldap_pmcs
-              cansub = true if list == 'private' and ldap_pmcs.include? 
dom.sub('.apache.org','')
-            end
+          elsif ldap_pmcs and list == 'private' and ldap_pmcs.include? 
dom.sub('.apache.org', '')
+            cansub = true
           end
           if pmc_chair and self.chairs_allowed.include? lid
             cansub = true
@@ -130,7 +130,7 @@ module ASF
           if lidonly
             allowed << lid
           else
-            allowed << [dom,list,lid]
+            allowed << [dom, list, lid]
           end
         end
       end
@@ -148,7 +148,7 @@ module ASF
 
       if sendmail
         # convert string keys to symbols
-        options = Hash[sendmail.map {|key, value| [key.to_sym, value.untaint]}]
+        options = Hash[sendmail.map {|key, value| [key.to_sym, value]}]
 
         # extract delivery method
         method = options.delete(:delivery_method).to_sym
@@ -168,6 +168,7 @@ module ASF
     # List of .qmail files that could clash with user ids (See: INFRA-14566)
     def self.qmail_ids
       return [] unless File.exist? '/srv/subscriptions/qmail.ids'
+
       File.read('/srv/subscriptions/qmail.ids').split
     end
 
@@ -178,10 +179,11 @@ module ASF
     end
 
     # Convert list name to form used in bin/.archives
-    def self.archivelistid(dom,list)
+    def self.archivelistid(dom, list)
       return "apachecon-#{list}" if dom == 'apachecon.com'
       return list if dom == 'apache.org'
-      dom.sub(".apache.org",'-') + list
+
+      dom.sub(".apache.org", '-') + list
     end
 
     # Canonicalise an email address, removing aliases and ignored punctuation
@@ -197,11 +199,12 @@ module ASF
       parts = email.split('@')
       if parts.length == 2
         name, dom = parts
-        return email if name.length == 0 || dom.length == 0
+        return email if name.empty? || dom.empty?
+
         dom.downcase!
         dom = 'gmail.com' if dom == 'googlemail.com' # same mailbox
         if dom == 'gmail.com'
-          return name.sub(/\+.*/,'').gsub('.','').downcase + '@' + dom
+          return name.sub(/\+.*/, '').gsub('.', '').downcase + '@' + dom
         else
           # Effectively the same:
           dom = 'apache.org' if dom == 'minotaur.apache.org'
@@ -235,9 +238,10 @@ module ASF
         lists = []
         File.open(@list_flags).each do |line|
           if line.match(/^F:-([a-zA-Z]{26}) (\S+) (\S+)/)
-            flags,dom,list=$1,$2,$3
+            flags, dom, list = $1, $2, $3
             next if list =~ /^infra-[a-z]$/ or (dom == 'incubator' and list == 
'infra-dev')
-            lists << [dom,list,flags]
+
+            lists << [dom, list, flags]
           else
             raise "Unexpected flags: #{line}"
           end
@@ -254,11 +258,12 @@ module ASF
     # Output:
     # yields: domain, list, flags
     def self.parse_flags(filter=nil)
-       self._load_flags()
-       @flags.each do |d,l,f|
-         next if filter and not f =~ filter
-         yield [d,l,f]
-       end
+      self._load_flags()
+      @flags.each do |d, l, f|
+        next if filter and f !~ filter
+
+        yield [d, l, f]
+      end
     end
 
     # Do the flags indicate subscription moderation?
@@ -280,11 +285,10 @@ module ASF
     # addresses.
     def obsolete_emails
       return @obsolete_emails if @obsolete_emails
+
       result = []
-      if icla
-        unless active_emails.any? {|mail| mail.downcase == icla.email.downcase}
-          result << icla.email
-        end
+      if icla && active_emails.none? {|mail| mail.downcase == 
icla.email.downcase}
+        result << icla.email
       end
       @obsolete_emails = result
     end

Reply via email to