You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2016/09/15 23:53:15 UTC

[whimsy] branch master updated (e39392f -> 1cd9f5b)

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

rubys pushed a change to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git.

      from  e39392f   untaint email addresses
       new  6aefcd7   refactor mail replies; add reject tasks
       new  1cd9f5b   center clear form button

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "adds" were already present in the repository and have only
been added to this reference.


Summary of changes:
 www/secmail/models/message.rb                      | 102 +++++++++++++++++++++
 www/secmail/public/secmail.css                     |   4 +
 www/secmail/templates/icla.erb                     |   7 +-
 www/secmail/templates/incomplete.erb               |   8 +-
 .../templates/{publickey.erb => pubkey.erb}        |   8 +-
 www/secmail/templates/unsigned.erb                 |   8 +-
 www/secmail/views/actions/icla.json.rb             |  42 +++------
 www/secmail/views/actions/incomplete.json.rb       |  30 ++++++
 www/secmail/views/actions/pubkey.json.rb           |  30 ++++++
 www/secmail/views/actions/unsigned.json.rb         |  30 ++++++
 www/secmail/views/forms/icla.js.rb                 |   4 +-
 www/secmail/views/forms/incomplete.js.rb           |   5 -
 www/secmail/views/forms/pubkey.rb                  |   5 -
 www/secmail/views/forms/unsigned.js.rb             |   5 -
 www/secmail/views/parts.js.rb                      |  50 ++++++----
 15 files changed, 251 insertions(+), 87 deletions(-)
 rename www/secmail/templates/{publickey.erb => pubkey.erb} (55%)
 create mode 100644 www/secmail/views/actions/incomplete.json.rb
 create mode 100644 www/secmail/views/actions/pubkey.json.rb
 create mode 100644 www/secmail/views/actions/unsigned.json.rb
 delete mode 100644 www/secmail/views/forms/incomplete.js.rb
 delete mode 100644 www/secmail/views/forms/pubkey.rb
 delete mode 100644 www/secmail/views/forms/unsigned.js.rb

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].

[whimsy] 01/02: refactor mail replies; add reject tasks

Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

commit 6aefcd7ce2121a389588dd7279cfab302ed48b2c
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Sep 15 19:52:29 2016 -0400

    refactor mail replies; add reject tasks
---
 www/secmail/models/message.rb                      | 102 +++++++++++++++++++++
 www/secmail/templates/icla.erb                     |   7 +-
 www/secmail/templates/incomplete.erb               |   8 +-
 .../templates/{publickey.erb => pubkey.erb}        |   8 +-
 www/secmail/templates/unsigned.erb                 |   8 +-
 www/secmail/views/actions/icla.json.rb             |  42 +++------
 www/secmail/views/actions/incomplete.json.rb       |  30 ++++++
 www/secmail/views/actions/pubkey.json.rb           |  30 ++++++
 www/secmail/views/actions/unsigned.json.rb         |  30 ++++++
 www/secmail/views/forms/incomplete.js.rb           |   5 -
 www/secmail/views/forms/pubkey.rb                  |   5 -
 www/secmail/views/forms/unsigned.js.rb             |   5 -
 www/secmail/views/parts.js.rb                      |  50 ++++++----
 13 files changed, 244 insertions(+), 86 deletions(-)

diff --git a/www/secmail/models/message.rb b/www/secmail/models/message.rb
index 05ee5b2..14a7958 100644
--- a/www/secmail/models/message.rb
+++ b/www/secmail/models/message.rb
@@ -179,6 +179,108 @@ class Message
   end
 
   #
+  # Construct a reply message, and in the process merge the email
+  # address from the original message (from, to, cc) with any additional
+  # address provided on the call (to, cc, bcc).  Remove any duplicates
+  # that may occur not only due to the merge, but also comparing across
+  # field types (for example, don't cc an address listed on the to field).
+  #
+  # Finally, canonicalize (format) the email addresses and ensure that
+  # the results aren't marked ask tainted, as the Ruby SMTP library will
+  # refuse to send to tainted addresses, and in the secretary mail application
+  # the addresses are expected to come from the mail archive and the
+  # secretary, both of which can be trusted.
+  #
+  def reply(fields)
+    mail = Mail.new
+
+    # fill in the from address
+    mail.from = fields[:from]
+
+    # fill in the reply to headers
+    mail.in_reply_to = self.id
+    mail.references = self.id
+
+    # fill in the subject from the original email
+    if self.subject =~ /^re:\s/i
+      mail.subject = self.subject
+    else
+      mail.subject = 'Re: ' + self.subject
+    end
+
+    # fill in the subject from the original email
+    mail.body = fields[:body]
+
+    # gather up the to, cc, and bcc addresses
+    to = []
+    cc = []
+    bcc = []
+
+    # process 'to' addresses on method call
+    if fields[:to]
+      Array(fields[:to]).compact.each do |addr|
+        addr = Mail::Address.new(addr) if addr.is_a? String
+        next if to.any? {|a| a.address = addr.address}
+        to << addr
+      end
+    end
+
+    # process 'from' addresses from original email
+    self.from.addrs.each do |addr|
+      next if to.any? {|a| a.address == addr.address}
+      if fields[:to]
+        next if cc.any? {|a| a.address == addr.address}
+        cc << addr
+      else
+        to << addr
+      end
+    end
+
+    # process 'to' addresses from original email
+    self.to.addrs.each do |addr|
+      next if to.any? {|a| a.address == addr.address}
+      next if cc.any? {|a| a.address == addr.address}
+      cc << addr
+    end
+
+    # process 'cc' addresses from original email
+    self.cc.each do |addr|
+      addr = Mail::Address.new(addr) if addr.is_a? String
+      next if to.any? {|a| a.address == addr.address}
+      cc << addr
+    end
+
+    # process 'cc' addresses on method call
+    if fields[:cc]
+      Array(fields[:cc]).compact.each do |addr|
+        addr = Mail::Address.new(addr) if addr.is_a? String
+        next if to.any? {|a| a.address == addr.address}
+        next if cc.any? {|a| a.address == addr.address}
+        cc << addr
+      end
+    end
+
+    # process 'bcc' addresses on method call
+    if fields[:bcc]
+      Array(fields[:bcc]).compact.each do |addr|
+        addr = Mail::Address.new(addr) if addr.is_a? String
+        next if to.any? {|a| a.address == addr.address}
+        next if cc.any? {|a| a.address == addr.address}
+        next if bcc.any? {|a| a.address == addr.address}
+        bcc << addr
+      end
+    end
+
+    # reformat and untaint email addresses
+    mail[:to] = to.map {|addr| addr.format.dup.untaint}
+    mail[:cc] = cc.map {|addr| addr.format.dup.untaint} unless cc.empty?
+    mail[:bcc] = bcc.map {|addr| addr.format.dup.untaint} unless bcc.empty?
+
+    # return the resulting email
+    mail
+  end
+
+  #
   # What to use as a hash for mail
   #
   def self.hash(message)
diff --git a/www/secmail/templates/icla.erb b/www/secmail/templates/icla.erb
index 995c04d..257f8d7 100644
--- a/www/secmail/templates/icla.erb
+++ b/www/secmail/templates/icla.erb
@@ -1,9 +1,4 @@
-To:   <%= @pubname.inspect %> <<%= @email %>>
-From: <%= @from %>
-Cc:   secretary@apache.org
-Subject: Your ICLA sent to Apache Secretary
-
-Dear <%= @pubname %>,
+Dear <%= @email.display_names.join(', ') %>,
 
 This message acknowledges receipt of your ICLA, which has been filed in the Apache Software Foundation records.
 
diff --git a/www/secmail/templates/incomplete.erb b/www/secmail/templates/incomplete.erb
index 9c64803..e692f3d 100644
--- a/www/secmail/templates/incomplete.erb
+++ b/www/secmail/templates/incomplete.erb
@@ -1,10 +1,4 @@
-to:   <%= @realname.inspect %> <<%= @nemail %>>
-from: <%= @from %>
-cc:   secretary@apache.org
-bcc:  <%= @bcc %>
-subject: Unsigned Document
-
-Dear <%= @realname %>,
+Dear <%= @email.display_names.join(', ') %>,
 
 We received this document but it appears to be incomplete.
 Please fill all required fields and resubmit all pages
diff --git a/www/secmail/templates/publickey.erb b/www/secmail/templates/pubkey.erb
similarity index 55%
rename from www/secmail/templates/publickey.erb
rename to www/secmail/templates/pubkey.erb
index 58dbbeb..e4f3ef1 100644
--- a/www/secmail/templates/publickey.erb
+++ b/www/secmail/templates/pubkey.erb
@@ -1,10 +1,4 @@
-to:   <%= @realname.inspect %> <<%= @pemail %>>
-from: <%= @from %>
-cc:   secretary@apache.org
-bcc:  <%= @bcc %>
-subject: Missing public key
-
-Dear <%= @realname %>,
+Dear <%= @email.display_names.join(', ') %>,
 
 We received this document but cannot verify your signature without
 your public key. Please upload your public key to pgpkeys.mit.edu.
diff --git a/www/secmail/templates/unsigned.erb b/www/secmail/templates/unsigned.erb
index 440041e..07cd251 100644
--- a/www/secmail/templates/unsigned.erb
+++ b/www/secmail/templates/unsigned.erb
@@ -1,10 +1,4 @@
-to:   <%= @realname.inspect %> <<%= @nemail %>>
-from: <%= @from %>
-cc:   secretary@apache.org
-bcc:  <%= @bcc %>
-subject: Unsigned Document
-
-Dear <%= @realname %>,
+Dear <%= @email.display_names.join(', ') %>,
 
 We received this document but it appears to be unsigned.
 Please sign and resubmit to secretary@apache.org
diff --git a/www/secmail/views/actions/icla.json.rb b/www/secmail/views/actions/icla.json.rb
index b53cd86..f940c76 100644
--- a/www/secmail/views/actions/icla.json.rb
+++ b/www/secmail/views/actions/icla.json.rb
@@ -112,29 +112,17 @@ end
 # send confirmation email
 task "email #@email" do
   # build mail from template
-  mail = Mail.new(template('icla.erb'))
-
-  # adjust copy lists
-  cc = mail.cc # from the template
-  cc += message.cc if message.cc # from the email message
-  cc << "private@#{pmc.mail_list}.apache.org" if pmc # copy pmc
-  cc << podling.private_mail_list if podling # copy podling
-  mail.cc = cc.uniq
-  mail.bcc = message.bcc - cc if message.bcc
-
-  # untaint email addresses
-  mail.to = mail.to.map {|email| email.dup.untaint}
-  mail.cc = mail.cc.map {|email| email.dup.untaint}
-  mail.bcc = mail.bcc.map {|email| email.dup.untaint} if message.bcc
-
-  # add reply info
-  mail.in_reply_to = message.id
-  mail.references = message.id
-  if message.subject =~ /^re:\s/i
-    mail.subject = message.subject
-  else
-    mail.subject = 'Re: ' + message.subject
-  end
+  @email = message.from
+  mail = message.reply(
+    from: @from,
+    to: @email.addrs,
+    cc: [
+      'secretary@apache.org',
+      ("private@#{pmc.mail_list}.apache.org" if pmc), # copy pmc
+      (podling.private_mail_list if podling) # copy podling
+    ],
+    body: template('icla.erb')
+  )
 
   # echo email
   form do
@@ -200,15 +188,13 @@ if @user and not @user.empty? and pmc and not @votelink.empty?
     mail = Mail.new(template('acreq.erb'))
 
     # adjust copy lists
-    cc = mail.cc # from the template
+    cc = mail.cc.split(',') # from the template
     cc << "private@#{pmc.mail_list}.apache.org" if pmc # copy pmc
     cc << podling.private_mail_list if podling # copy podling
-    mail.cc = cc.uniq
+    mail.cc = cc.uniq.map {|email| email.dup.untaint}
 
-    # untaint email addresses
+    # untaint to email addresses
     mail.to = mail.to.map {|email| email.dup.untaint}
-    mail.cc = mail.cc.map {|email| email.dup.untaint}
-    mail.bcc = mail.bcc.map {|email| email.dup.untaint} if message.bcc
 
     # echo email
     form do
diff --git a/www/secmail/views/actions/incomplete.json.rb b/www/secmail/views/actions/incomplete.json.rb
new file mode 100644
index 0000000..97a5c60
--- /dev/null
+++ b/www/secmail/views/actions/incomplete.json.rb
@@ -0,0 +1,30 @@
+# extract message
+message = Mailbox.find(@message)
+
+# obtain per-user information
+_personalize_email(env.user)
+
+########################################################################
+#                           email submitter                            #
+########################################################################
+
+# send rejection email
+task "email #{message.from}" do
+  # build mail from template
+  @email = message.from
+  mail = message.reply(
+    from: @from,
+    cc: 'secretary@apache.org',
+    body: template('incomplete.erb')
+  )
+
+  # echo email
+  form do
+    _message mail.to_s
+  end
+
+  # deliver mail
+  complete do
+    mail.deliver!
+  end
+end
diff --git a/www/secmail/views/actions/pubkey.json.rb b/www/secmail/views/actions/pubkey.json.rb
new file mode 100644
index 0000000..f445cd3
--- /dev/null
+++ b/www/secmail/views/actions/pubkey.json.rb
@@ -0,0 +1,30 @@
+# extract message
+message = Mailbox.find(@message)
+
+# obtain per-user information
+_personalize_email(env.user)
+
+########################################################################
+#                           email submitter                            #
+########################################################################
+
+# send rejection email
+task "email #{message.from}" do
+  # build mail from template
+  @email = message.from
+  mail = message.reply(
+    from: @from,
+    cc: 'secretary@apache.org',
+    body: template('pubkey.erb')
+  )
+
+  # echo email
+  form do
+    _message mail.to_s
+  end
+
+  # deliver mail
+  complete do
+    mail.deliver!
+  end
+end
diff --git a/www/secmail/views/actions/unsigned.json.rb b/www/secmail/views/actions/unsigned.json.rb
new file mode 100644
index 0000000..0e5e4c6
--- /dev/null
+++ b/www/secmail/views/actions/unsigned.json.rb
@@ -0,0 +1,30 @@
+# extract message
+message = Mailbox.find(@message)
+
+# obtain per-user information
+_personalize_email(env.user)
+
+########################################################################
+#                           email submitter                            #
+########################################################################
+
+# send rejection email
+task "email #{message.from}" do
+  # build mail from template
+  @email = message.from
+  mail = message.reply(
+    from: @from,
+    cc: 'secretary@apache.org',
+    body: template('unsigned.erb')
+  )
+
+  # echo email
+  form do
+    _message mail.to_s
+  end
+
+  # deliver mail
+  complete do
+    mail.deliver!
+  end
+end
diff --git a/www/secmail/views/forms/incomplete.js.rb b/www/secmail/views/forms/incomplete.js.rb
deleted file mode 100644
index 004ca9c..0000000
--- a/www/secmail/views/forms/incomplete.js.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class Incomplete < React
-  def render
-    _p 'INCOMPLETE'
-  end
-end
diff --git a/www/secmail/views/forms/pubkey.rb b/www/secmail/views/forms/pubkey.rb
deleted file mode 100644
index 80344b1..0000000
--- a/www/secmail/views/forms/pubkey.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class PubKey < React
-  def render
-    _p 'Public Key'
-  end
-end
diff --git a/www/secmail/views/forms/unsigned.js.rb b/www/secmail/views/forms/unsigned.js.rb
deleted file mode 100644
index 046acc0..0000000
--- a/www/secmail/views/forms/unsigned.js.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class Unsigned < React
-  def render
-    _p 'UNSIGNED'
-  end
-end
diff --git a/www/secmail/views/parts.js.rb b/www/secmail/views/parts.js.rb
index 7f1ed4d..9dcd6b9 100644
--- a/www/secmail/views/parts.js.rb
+++ b/www/secmail/views/parts.js.rb
@@ -115,22 +115,30 @@ class Parts < React
 
           _hr
 
-          _label do
-            _input type: 'radio', name: 'doctype', value: 'incomplete',
-              onClick: -> {@form = Incomplete}
-            _span 'incomplete form'
-          end
-
-          _label do
-            _input type: 'radio', name: 'doctype', value: 'unsigned',
-              onClick: -> {@form = Unsigned}
-            _span 'unsigned form'
-          end
-
-          _label do
-            _input type: 'radio', name: 'doctype', value: 'pubkey',
-              onClick: -> {@form = Unsigned}
-            _span 'upload public key'
+          # reject message with message
+          _form method: 'POST', target: 'content' do
+            _input type: 'hidden', name: 'message',
+              value: window.parent.location.pathname
+            _input type: 'hidden', name: 'selected', value: @@selected
+            _input type: 'hidden', name: 'signature', value: @@signature
+
+            _label do
+              _input type: 'radio', name: 'doctype', value: 'incomplete',
+                onClick: self.reject
+              _span 'incomplete form'
+            end
+
+            _label do
+              _input type: 'radio', name: 'doctype', value: 'unsigned',
+                onClick: self.reject
+              _span 'unsigned form'
+            end
+
+            _label do
+              _input type: 'radio', name: 'doctype', value: 'pubkey',
+                onClick: self.reject
+              _span 'upload public key'
+            end
           end
         end
 
@@ -355,6 +363,16 @@ class Parts < React
   end
 
   ########################################################################
+  #                         Reject attachment                            #
+  ########################################################################
+
+  def reject(event)
+    form = jQuery(event.target).closest('form')
+    form.attr('action', "../../tasklist/#{event.target.value}")
+    form.submit()
+  end
+
+  ########################################################################
   #                            Miscellaneous                             #
   ########################################################################
 

-- 
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.

[whimsy] 02/02: center clear form button

Posted by ru...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

commit 1cd9f5b968f96380dd18fdf6facfa5a2106f17f0
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Sep 15 19:52:55 2016 -0400

    center clear form button
---
 www/secmail/public/secmail.css     | 4 ++++
 www/secmail/views/forms/icla.js.rb | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/www/secmail/public/secmail.css b/www/secmail/public/secmail.css
index 843556b..2510e05 100644
--- a/www/secmail/public/secmail.css
+++ b/www/secmail/public/secmail.css
@@ -176,3 +176,7 @@ pre.bg-info {
 #tasklist input, #tasklist textarea {
   width: 100%;
 }
+
+#parts table {
+  margin-top: 14px; 
+}
diff --git a/www/secmail/views/forms/icla.js.rb b/www/secmail/views/forms/icla.js.rb
index 22d1fd9..74a492d 100644
--- a/www/secmail/views/forms/icla.js.rb
+++ b/www/secmail/views/forms/icla.js.rb
@@ -8,7 +8,9 @@ class ICLA < React
   def render
     _h4 'ICLA'
 
-    _button 'clear form', onClick: -> {@pubname = @realname = @email = ''}
+    _div.buttons do
+      _button 'clear form', onClick: -> {@pubname = @realname = @email = ''}
+    end
 
     _form method: 'post', action: '../../tasklist/icla', target: 'content' do
       _input type: 'hidden', name: 'message'

-- 
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.