Skip to content

Commit 1dbd0f3

Browse files
committed
Fix file upload handling for special characters
Remove dfm_htmlspecialchars() from upload filename transmission. HTML-escaping was causing double-encoding: foo&bar.zip became foo&bar.zip on filesystem. Changes: - Remove dfm_htmlspecialchars() when building filePath for upload - Remove dfm_htmlspecialchars() from cleanup file parameter - Add escapeHtml() for upload progress display (HTML context) - Filename is now correctly transmitted via encodeURIComponent/rawurldecode Result: File "foo&bar.zip" now uploads as "foo&bar.zip" on disk, and displays correctly in upload progress.
1 parent 74572a2 commit 1dbd0f3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

emhttp/plugins/dynamix/Browse.page

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ function uploadFile(files,index,start,time) {
12451245

12461246
var xhr = new XMLHttpRequest();
12471247
currentXhr = xhr; // Store for abort capability
1248-
var filePath = dir.replace(/\/+$/, '') + '/' + dfm_htmlspecialchars(file.name);
1248+
var filePath = dir.replace(/\/+$/, '') + '/' + file.name;
12491249
var url = '/webGui/include/Control.php?mode=upload&file=' + encodeURIComponent(filePath) + '&start=' + start + '&cancel=' + cancel;
12501250
xhr.open('POST', url, true);
12511251
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
@@ -1276,11 +1276,11 @@ function uploadFile(files,index,start,time) {
12761276
var elapsedSeconds = (d.getTime() - time) / 1000;
12771277
var speed = autoscale(bytesTransferred / elapsedSeconds);
12781278
var percent = Math.floor(bytesTransferred / total * 100);
1279-
$('#dfm_uploadStatus').html("_(Uploading)_: <span class='dfm_percent'>"+percent+"%</span><span class='dfm_speed'>Speed: "+speed+"</span><span class='orange-text'> ["+(index+1)+'/'+files.length+']&nbsp;&nbsp;'+file.name+"</span>");
1279+
$('#dfm_uploadStatus').html("_(Uploading)_: <span class='dfm_percent'>"+percent+"%</span><span class='dfm_speed'>Speed: "+speed+"</span><span class='orange-text'> ["+(index+1)+'/'+files.length+']&nbsp;&nbsp;'+escapeHtml(file.name)+"</span>");
12801280
uploadFile(files,index,next,time);
12811281
} else if (index < files.length-1) {
12821282
// Clean up temp file for completed upload before starting next file
1283-
$.post('/webGui/include/Control.php',{mode:'stop',file:encodeURIComponent(dfm_htmlspecialchars(file.name))});
1283+
$.post('/webGui/include/Control.php',{mode:'stop',file:encodeURIComponent(file.name)});
12841284
uploadFile(files,index+1,0,time);
12851285
} else {stopUpload(file.name); return;}
12861286
};

0 commit comments

Comments
 (0)