瀏覽代碼

Fix #43: Validate special characters in filename before rendering caption

Kartik Visweswaran 10 年之前
父節點
當前提交
18f76c961d
共有 3 個文件被更改,包括 7 次插入3 次删除
  1. 3 2
      CHANGE.md
  2. 4 1
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 3 - 2
CHANGE.md

@@ -2,9 +2,10 @@ version 2.6.0
 =============
 **Date:** 15-Oct-2014
 
-- (enh #42): Enhance plugin to configure the `elErrorContainer` for displaying validation errors.
-- Templatize errorContainer for display within the preview window.
 - (bug #40): More correct fix for IE (ver < 11) inability to clear fileinput values.
+- Templatize errorContainer for display within the preview window.
+- (enh #42): Enhance plugin to configure the `elErrorContainer` for displaying validation errors.
+- (bug #43): Validate special characters in filename before generating caption.
 
 version 2.5.0
 =============

+ 4 - 1
js/fileinput.js

@@ -623,8 +623,11 @@
             }
             readFile(0);
         },
+        slug: function (text) {
+            return isEmpty(text) ? '' : text.replace(/[^\w-. ]+/g,'');
+        },
         change: function (e) {
-            var self = this, $el = self.$element, label = $el.val().replace(/\\/g, '/').replace(/.*\//, ''),
+            var self = this, $el = self.$element, label = self.slug($el.val()),
                 total = 0, $preview = self.$preview, files = $el.get(0).files, msgSelected = self.msgSelected,
                 numFiles = !isEmpty(files) ? (files.length + self.initialPreviewCount) : 1, tfiles;
             self.hideFileIcon();

文件差異過大導致無法顯示
+ 0 - 0
js/fileinput.min.js


部分文件因文件數量過多而無法顯示