mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-20 14:39:53 +01:00
Merge pull request #1879 from Gared/binary-upload-fix
Add check if uploaded file only contains ascii chars when abiword disabled
This commit is contained in:
commit
c4fcedbb8d
1 changed files with 24 additions and 0 deletions
|
@ -113,6 +113,30 @@ exports.doImport = function(req, res, padId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
function(callback) {
|
||||||
|
if (!abiword) {
|
||||||
|
// Read the file with no encoding for raw buffer access.
|
||||||
|
fs.readFile(destFile, function(err, buf) {
|
||||||
|
if (err) throw err;
|
||||||
|
var isAscii = true;
|
||||||
|
// Check if there are only ascii chars in the uploaded file
|
||||||
|
for (var i=0, len=buf.length; i<len; i++) {
|
||||||
|
if (buf[i] > 240) {
|
||||||
|
isAscii=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isAscii) {
|
||||||
|
callback();
|
||||||
|
} else {
|
||||||
|
callback("uploadFailed");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
//get the pad object
|
//get the pad object
|
||||||
function(callback) {
|
function(callback) {
|
||||||
padManager.getPad(padId, function(err, _pad){
|
padManager.getPad(padId, function(err, _pad){
|
||||||
|
|
Loading…
Reference in a new issue