[config] Add svg as supported image ext. For bug 37564

This commit is contained in:
Sergey Konovalov
2023-07-28 16:45:57 +03:00
parent c3fcb04e5c
commit bf0aab40f7
3 changed files with 5 additions and 22 deletions

View File

@ -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",

View File

@ -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;
};

View File

@ -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) {