whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [4/5] Commit 58ad13d: file documents with signatures
Date Wed, 06 Jan 2016 20:17:44 GMT
Commit 58ad13d9fdbf2b40ce93d9e08ac8d5c449c2a198:
    file documents with signatures


Branch: refs/heads/secmail
Author: Sam Ruby <rubys@intertwingly.net>
Committer: Sam Ruby <rubys@intertwingly.net>
Pusher: rubys <rubys@apache.org>

------------------------------------------------------------
www/secmail/helpers.rb                                       | + -
www/secmail/models/attachment.rb                             | + --------
www/secmail/models/message.rb                                | ++++++ ------
www/secmail/public/secmail.css                               | + -
www/secmail/views/forms/icla.js.rb                           | ++++++++ -
------------------------------------------------------------
42 changes: 18 additions, 24 deletions.
------------------------------------------------------------


diff --git a/www/secmail/helpers.rb b/www/secmail/helpers.rb
index 52048c0..1bb3732 100644
--- a/www/secmail/helpers.rb
+++ b/www/secmail/helpers.rb
@@ -5,7 +5,7 @@ def svn_reset(repos)
     out, err, rc = Open3.capture3 'svn', 'cleanup', path
     out, err, rc = Open3.capture3 'svn', 'revert', '--recursive', path
     out, err, rc = Open3.capture3 'svn', 'status', path
-    File.unlink *out.scan(/^\?\s+(.*)/).flatten.map(&:untaint)
+    FileUtils.rm_rf out.scan(/^\?\s+(.*)/).flatten.map(&:untaint)
     out, err, rc = Open3.capture3 'svn', 'update', path
   end
 
diff --git a/www/secmail/models/attachment.rb b/www/secmail/models/attachment.rb
index d2fbd83..fb26513 100644
--- a/www/secmail/models/attachment.rb
+++ b/www/secmail/models/attachment.rb
@@ -56,23 +56,10 @@ def as_pdf
 
   # write a file out to svn
   def write_svn(repos, file)
-    if file.start_with? '.' or file !~ /\A[-.\w]+\Z/
-      raise IOError.new("Invalid filename: #{file}")
-    end
-
     filename = File.join(repos, file)
+    filename = File.join(filename, safe_name) if Dir.exist? filename
 
-    if Dir.exist? filename
-      if name.start_with? '.' or name !~ /\A[.\w]+\Z/
-        raise IOError.new("Invalid filename: #{name}")
-      end
-
-      filename = File.join(filename, name)
-      raise Errno::EEXIST.new(File.join(file, name)) if File.exist? filename
-    else
-      raise Errno::EEXIST.new(file) if File.exist? filename
-    end
-
+    raise Errno::EEXIST.new(file) if File.exist? filename
     File.write filename, body, encoding: Encoding::BINARY
 
     system 'svn', 'add', filename
diff --git a/www/secmail/models/message.rb b/www/secmail/models/message.rb
index 2335259..9b3ad54 100644
--- a/www/secmail/models/message.rb
+++ b/www/secmail/models/message.rb
@@ -100,24 +100,24 @@ def write_svn(repos, filename, *attachments)
       find(attachments.first).write_svn(repos, filename + ext)
     else
       # validate filename
-      if filename.start_with? '.' or filename !~ /\A[.\w]\Z/
-	 raise IOError.new("invalid filename: #{filename}")
+      unless filename =~ /\A[a-zA-Z][-.\w]+\Z/
+	      raise IOError.new("invalid filename: #{filename}")
       end
 
       # ensure directory doesn't exist
-      dest = File.join(iclas, filename).untaint
+      dest = File.join(repos, filename).untaint
       raise Errno::EEXIST.new(filename) if File.exist? dest
 
       # create directory
       Dir.mkdir dest
-      Kernel.system 'svn', 'add', dest
 
       # write out selected attachment
       attachments.each do |attachment|
-        find(attachment).write_svn(repos, dest)
+        find(attachment).write_svn(repos, filename)
       end
 
-      File.join(repos, dest)
+      Kernel.system 'svn', 'add', dest
+      dest
     end
   end
 end
diff --git a/www/secmail/public/secmail.css b/www/secmail/public/secmail.css
index 3470fc1..d85f58d 100644
--- a/www/secmail/public/secmail.css
+++ b/www/secmail/public/secmail.css
@@ -98,7 +98,7 @@ ul.contextMenu {
   cursor: pointer;
 }
 
-.busy, .busy input, .busy .contextMenu li:hover {
+.busy, .busy input, .busy input:disabled, .busy .contextMenu li:hover {
   cursor: wait;
 }
 
diff --git a/www/secmail/views/forms/icla.js.rb b/www/secmail/views/forms/icla.js.rb
index 720268b..e7551c0 100644
--- a/www/secmail/views/forms/icla.js.rb
+++ b/www/secmail/views/forms/icla.js.rb
@@ -2,6 +2,7 @@ class ICLA < React
   def initialize
     @filed = false
     @checked = nil
+    @submitted = false
   end
 
   def render
@@ -96,7 +97,7 @@ def componentDidUpdate()
       document.querySelector("input[name=#{name}]").validity.valid
     end
 
-    $file.disabled = !valid or @filed
+    $file.disabled = !valid or @filed or @submitted
 
     # new account request form
     valid = true
@@ -117,9 +118,15 @@ def genfilename()
 
   # handle ICLA form submission
   def file(event)
+    @submitted = true
+
     @@submit.call(event).then {|response|
       @filed = true
+      @submitted = false
       alert response.result
+    }.catch {
+      @filed = false
+      @submitted = false
     }
   end
 

Mime
View raw message