[Rt-commit] rt branch, 4.2/alert-invalid-file-inputs, created. rt-4.0.0rc4-65-g2a88425

Alex Vandiver alexmv at bestpractical.com
Wed Jul 20 14:40:15 EDT 2011


The branch, 4.2/alert-invalid-file-inputs has been created
        at  2a8842566c348010768dc490c21f4217d75846ee (commit)

- Log -----------------------------------------------------------------
commit 00b00aa57863d9f2b6f784f26abb08bcaafc3ecc
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Mar 2 18:00:35 2011 +0800

    CGI, HTTP::Body and MIME::Entity do *not* support double quotes in filenames,let's warn users for this. see also #16119

diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index bc507dc..bbc846c 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -69,6 +69,15 @@ $onload => undef
 % if ( RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'})) {
     jQuery().ready(function ()  { ReplaceAllTextareas('<%$m->request_args->{'CKeditorEncoded'} || 0 %>') });
 % }
+
+
+jQuery( function() {
+    jQuery("input[type=file]").change( function() {
+            checkFileInput(this); 
+        } );
+    }
+);
+
 --></script>
 
 <%INIT>
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index 58855a6..82fe409 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -345,3 +345,12 @@ function addprincipal_onchange(ev, ui) {
 function escapeCssSelector(str) {
     return str.replace(/([^A-Za-z0-9_-])/g,'\\$1');
 }
+
+function checkFileInput ( element ) {
+    var val = jQuery(element).val();
+    if ( val && val.match( /"/ ) ) {
+        alert("filename contains double quote(\"), which is not supported");
+        jQuery(element).val('');
+    }
+}
+

commit 05ff817d118c92f25c33713e60cbd7e27617a809
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 3 12:32:25 2011 +0800

    we should put js into .js files amap

diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index bbc846c..5e01887 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -71,13 +71,6 @@ $onload => undef
 % }
 
 
-jQuery( function() {
-    jQuery("input[type=file]").change( function() {
-            checkFileInput(this); 
-        } );
-    }
-);
-
 --></script>
 
 <%INIT>
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index 82fe409..9c3d9bd 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -354,3 +354,10 @@ function checkFileInput ( element ) {
     }
 }
 
+jQuery( function() {
+    jQuery("input[type=file]").change( function() {
+            checkFileInput(this);
+        } );
+    }
+);
+

commit 2a8842566c348010768dc490c21f4217d75846ee
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Mar 16 13:19:33 2011 +0800

    alert() is jarring

diff --git a/share/html/NoAuth/css/base/forms.css b/share/html/NoAuth/css/base/forms.css
index 9c6c2a5..854b7e9 100755
--- a/share/html/NoAuth/css/base/forms.css
+++ b/share/html/NoAuth/css/base/forms.css
@@ -263,6 +263,12 @@ form div.submit div.buttons div.next {
     width: 50%;
 }
 
+div.invalid {
+    font-style: italic;
+    color: red;
+    display: inline;
+}
+
 /* query builder */
 
 #formatbuttons {
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index 9c3d9bd..da3b251 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -349,14 +349,35 @@ function escapeCssSelector(str) {
 function checkFileInput ( element ) {
     var val = jQuery(element).val();
     if ( val && val.match( /"/ ) ) {
-        alert("filename contains double quote(\"), which is not supported");
-        jQuery(element).val('');
+        return false;
+    }
+    else {
+        return true;
     }
 }
 
 jQuery( function() {
     jQuery("input[type=file]").change( function() {
-            checkFileInput(this);
+            var invalid_div = jQuery(this).next().hasClass('invalid') ?
+jQuery(this).next() : false;
+
+            if ( checkFileInput(this) ) {
+                if ( invalid_div ) {
+                    invalid_div.hide();
+                }
+            }
+            else {
+                if ( invalid_div  ) {
+                    invalid_div.show();
+                }
+                else {
+                    jQuery(this).after(
+                        '<div class="invalid">filename can not contain double quotes</div>'
+                    );
+                    jQuery(this).val('');
+
+                }
+            }
         } );
     }
 );

-----------------------------------------------------------------------


More information about the Rt-commit mailing list