fix #356
This commit is contained in:
parent
88c4428014
commit
24662f87f8
5 changed files with 34 additions and 6 deletions
|
@ -27,6 +27,7 @@ import javax.annotation.Resource;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.codelibs.core.io.FileUtil;
|
||||
import org.codelibs.core.io.ResourceUtil;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.Constants;
|
||||
|
@ -134,22 +135,26 @@ public class AdminDesignAction extends FessAdminAction implements Serializable {
|
|||
throwValidationError(messages -> messages.addErrorsDesignFileNameIsNotFound("designFile"), () -> asListHtml());
|
||||
}
|
||||
|
||||
String baseDir = null;
|
||||
File uploadFile = null;
|
||||
// normalize filename
|
||||
if (checkFileType(fileName, fessConfig.getSupportedUploadedMediaExtentionsAsArray())
|
||||
&& checkFileType(uploadedFileName, fessConfig.getSupportedUploadedMediaExtentionsAsArray())) {
|
||||
baseDir = "/images/";
|
||||
uploadFile = new File(getServletContext().getRealPath("/images/" + fileName));
|
||||
} else if (checkFileType(fileName, fessConfig.getSupportedUploadedCssExtentionsAsArray())
|
||||
&& checkFileType(uploadedFileName, fessConfig.getSupportedUploadedCssExtentionsAsArray())) {
|
||||
baseDir = "/css/";
|
||||
uploadFile = new File(getServletContext().getRealPath("/css/" + fileName));
|
||||
} else if (checkFileType(fileName, fessConfig.getSupportedUploadedJsExtentionsAsArray())
|
||||
&& checkFileType(uploadedFileName, fessConfig.getSupportedUploadedJsExtentionsAsArray())) {
|
||||
baseDir = "/js/";
|
||||
uploadFile = new File(getServletContext().getRealPath("/js/" + fileName));
|
||||
} else if (fessConfig.isSupportedUploadedFile(fileName) || fessConfig.isSupportedUploadedFile(uploadedFileName)) {
|
||||
uploadFile = ResourceUtil.getResourceAsFileNoException(fileName);
|
||||
if (uploadFile == null) {
|
||||
throwValidationError(messages -> messages.addErrorsDesignFileNameIsNotFound("designFileName"), () -> asListHtml());
|
||||
}
|
||||
} else {
|
||||
throwValidationError(messages -> messages.addErrorsDesignFileIsUnsupportedType("designFileName"), () -> asListHtml());
|
||||
}
|
||||
|
||||
final File uploadFile = new File(getServletContext().getRealPath(baseDir + fileName));
|
||||
final File parentFile = uploadFile.getParentFile();
|
||||
if (!parentFile.exists() && !parentFile.mkdirs()) {
|
||||
logger.warn("Could not create " + parentFile.getAbsolutePath());
|
||||
|
|
|
@ -779,7 +779,7 @@ public class FessLabels extends ActionMessages {
|
|||
/** The key of the message: Search */
|
||||
public static final String LABELS_index_form_search_btn = "{labels.index_form_search_btn}";
|
||||
|
||||
/** The key of the message: Fess Search */
|
||||
/** The key of the message: Search */
|
||||
public static final String LABELS_index_osdd_title = "{labels.index_osdd_title}";
|
||||
|
||||
/** The key of the message: Options */
|
||||
|
|
|
@ -102,6 +102,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
/** The key of the configuration. e.g. jpg,jpeg,gif,png,swf */
|
||||
String SUPPORTED_UPLOADED_MEDIA_EXTENTIONS = "supported.uploaded.media.extentions";
|
||||
|
||||
/** The key of the configuration. e.g. license.properties */
|
||||
String SUPPORTED_UPLOADED_FILES = "supported.uploaded.files";
|
||||
|
||||
/** The key of the configuration. e.g. ar,bg,ca,da,de,el,en,es,eu,fa,fi,fr,ga,gl,hi,hu,hy,id,it,ja,lv,ko,nl,no,pt,ro,ru,sv,th,tr,zh_CN,zh_TW,zh */
|
||||
String SUPPORTED_LANGUAGES = "supported.languages";
|
||||
|
||||
|
@ -804,6 +807,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
String getSupportedUploadedMediaExtentions();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'supported.uploaded.files'. <br>
|
||||
* The value is, e.g. license.properties <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getSupportedUploadedFiles();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'supported.languages'. <br>
|
||||
* The value is, e.g. ar,bg,ca,da,de,el,en,es,eu,fa,fi,fr,ga,gl,hi,hu,hy,id,it,ja,lv,ko,nl,no,pt,ro,ru,sv,th,tr,zh_CN,zh_TW,zh <br>
|
||||
|
@ -2523,6 +2533,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
return get(FessConfig.SUPPORTED_UPLOADED_MEDIA_EXTENTIONS);
|
||||
}
|
||||
|
||||
public String getSupportedUploadedFiles() {
|
||||
return get(FessConfig.SUPPORTED_UPLOADED_FILES);
|
||||
}
|
||||
|
||||
public String getSupportedLanguages() {
|
||||
return get(FessConfig.SUPPORTED_LANGUAGES);
|
||||
}
|
||||
|
|
|
@ -411,4 +411,12 @@ public interface FessProp {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String getSupportedUploadedFiles();
|
||||
|
||||
public default boolean isSupportedUploadedFile(String name) {
|
||||
return StreamUtil.of(getSuggestPopularWordExcludes().split(",")).filter(s -> StringUtil.isNotBlank(s))
|
||||
.anyMatch(s -> s.equals(name));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ max.log.output.length=4000
|
|||
supported.uploaded.js.extentions=js
|
||||
supported.uploaded.css.extentions=css
|
||||
supported.uploaded.media.extentions=jpg,jpeg,gif,png,swf
|
||||
supported.uploaded.files=license.properties
|
||||
supported.languages=ar,bg,ca,da,de,el,en,es,eu,fa,fi,fr,ga,gl,hi,hu,hy,id,it,ja,lv,ko,nl,no,pt,ro,ru,sv,th,tr,zh_CN,zh_TW,zh
|
||||
|
||||
# ========================================================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue