You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/11/29 12:34:45 UTC

[whimsy] branch master updated: Use library method for file check; match whole filename

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 25a4707  Use library method for file check; match whole filename
25a4707 is described below

commit 25a4707cb24b406dc1f68fe2a307d864a149907e
Author: Sebb <se...@apache.org>
AuthorDate: Fri Nov 29 12:34:31 2019 +0000

    Use library method for file check; match whole filename
    
    Also catch names that fail validation just in case
---
 www/secretary/workbench/views/actions/ccla.json.rb | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/www/secretary/workbench/views/actions/ccla.json.rb b/www/secretary/workbench/views/actions/ccla.json.rb
index f453387..bcf16e9 100644
--- a/www/secretary/workbench/views/actions/ccla.json.rb
+++ b/www/secretary/workbench/views/actions/ccla.json.rb
@@ -11,12 +11,16 @@ message = Mailbox.find(@message)
 # extract file extension
 fileext = File.extname(@selected).downcase if @signature.empty?
 
+ccla = "#@filename#{fileext}"
+
 # verify that a CCLA under that name doesn't already exist
-if "#@filename#{fileext}" =~ /\w[-\w]*\.?\w*/
-  ccla = "#{ASF::SVN['cclas']}/#@filename#{fileext}"
-  if File.exist? ccla.untaint
-    _warn "documents/cclas/#@filename#{fileext} already exists"
+if ccla =~ /^\w[-\w]*\.?\w*$/
+  if ASF::CCLAFiles.exist?(ccla.untaint)
+    _warn "documents/cclas/#{ccla} already exists"
   end
+else
+  # Should not be possible, as form checks for: '[a-zA-Z][-\w]+(\.[a-z]+)?'
+  _warn "#{ccla} is not a valid file name"
 end
 
 # extract/verify project