mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[config] Add svg as supported image ext. For bug 37564
This commit is contained in:
@ -163,7 +163,7 @@
|
||||
"utils": {
|
||||
"utils_common_fontdir": "null",
|
||||
"utils_fonts_search_patterns": "*.ttf;*.ttc;*.otf",
|
||||
"limits_image_types_upload": "jpg;jpeg;jpe;png;gif;bmp"
|
||||
"limits_image_types_upload": "jpg;jpeg;jpe;png;gif;bmp;svg"
|
||||
},
|
||||
"sql": {
|
||||
"type": "postgres",
|
||||
|
||||
@ -37,7 +37,7 @@ var constants = require('./constants');
|
||||
|
||||
function getImageFormatBySignature(buffer) {
|
||||
var length = buffer.length;
|
||||
var startText = buffer.toString('ascii', 0, 20);
|
||||
var startText = buffer.toString('ascii', 0, 100);
|
||||
|
||||
//jpeg
|
||||
// Hex: FF D8 FF
|
||||
@ -187,8 +187,7 @@ function getImageFormatBySignature(buffer) {
|
||||
}
|
||||
|
||||
//svg
|
||||
//works for svgs created in the editor, external svgs can be with spaces at the beginning
|
||||
if (0 == startText.indexOf('<svg')) {
|
||||
if (-1 !== startText.indexOf('<svg')) {
|
||||
return constants.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_SVG;
|
||||
}
|
||||
|
||||
@ -500,26 +499,14 @@ exports.getStringFromFormat = function(format) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
exports.getImageFormat = function(ctx, buffer, optExt) {
|
||||
exports.getImageFormat = function(ctx, buffer) {
|
||||
var format = constants.AVS_OFFICESTUDIO_FILE_UNKNOWN;
|
||||
try {
|
||||
//signature
|
||||
format = getImageFormatBySignature(buffer);
|
||||
//return type by extension
|
||||
if (constants.AVS_OFFICESTUDIO_FILE_UNKNOWN == format && optExt) {
|
||||
if ('.svg' == optExt) {
|
||||
format = constants.AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_SVG;
|
||||
} else {
|
||||
//try by extension
|
||||
if (optExt.length > 0 && '.' == optExt[0]) {
|
||||
optExt = optExt.substring(1);
|
||||
}
|
||||
format = exports.getFormatFromString(optExt);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
ctx.logger.error('error getImageFormat ext=%s: %s', optExt, e.stack);
|
||||
ctx.logger.error('error getImageFormat: %s', e.stack);
|
||||
}
|
||||
return format;
|
||||
};
|
||||
|
||||
@ -745,10 +745,6 @@ function* commandImgurls(ctx, conn, cmd, outputData) {
|
||||
formatStr = formatChecker.getStringFromFormat(format);
|
||||
if (formatStr && -1 !== supportedFormats.indexOf(formatStr)) {
|
||||
isAllow = true;
|
||||
} else if ('svg' === formatStr && isDisplayedImage(pathModule.basename(urlParsed.pathname)) > 0) {
|
||||
//paste case
|
||||
//todo refactoring
|
||||
isAllow = true;
|
||||
}
|
||||
}
|
||||
if (!isAllow && urlParsed) {
|
||||
|
||||
Reference in New Issue
Block a user