summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2012-08-07 22:33:14 (GMT)
committercatch2012-08-07 22:33:14 (GMT)
commit9d3e5e4cddae06c4290f31ffe07a1e3164a3f902 (patch)
tree4cebbb3f8ef965c1ea480d469d1bd26f120bc607
parent29bfbf491a3998fb3f7a39dc8cefb11647f101f7 (diff)
Issue #1037632 by Sheldon Rampton, Tor Arne Thune: Fixed Attaching a forbidden file to a node gives an error message with bogus file path.
-rw-r--r--core/modules/file/file.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/modules/file/file.js b/core/modules/file/file.js
index 28237ea..5f21ca5 100644
--- a/core/modules/file/file.js
+++ b/core/modules/file/file.js
@@ -88,7 +88,14 @@ Drupal.file = Drupal.file || {
var acceptableMatch = new RegExp('\\.(' + extensionPattern + ')$', 'gi');
if (!acceptableMatch.test(this.value)) {
var error = Drupal.t("The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions.", {
- '%filename': this.value,
+ // According to the specifications of HTML5, a file upload control
+ // should not reveal the real local path to the file that a user
+ // has selected. Some web browsers implement this restriction by
+ // replacing the local path with "C:\fakepath\", which can cause
+ // confusion by leaving the user thinking perhaps Drupal could not
+ // find the file because it messed up the file path. To avoid this
+ // confusion, therefore, we strip out the bogus fakepath string.
+ '%filename': this.value.replace('C:\\fakepath\\', ''),
'%extensions': extensionPattern.replace(/\|/g, ', ')
});
$(this).closest('div.form-managed-file').prepend('<div class="messages error file-upload-js-error">' + error + '</div>');