1,优化URL报错,2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增多种类型文件预览 (#419)
1,优化URL报错 2,更新OFD组件 3,美化Excel 4,文本方法关闭字节流 5,新增xmind、eml、epub、"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"格式 Co-authored-by: gaoxiongzaq <admin@cxcp.com>
This commit is contained in:
@ -25,11 +25,19 @@ public enum FileType {
|
||||
CAD("cadFilePreviewImpl"),
|
||||
TIFF("tiffFilePreviewImpl"),
|
||||
OFD("ofdFilePreviewImpl"),
|
||||
SVG("svgFilePreviewImpl");
|
||||
EML("emlFilePreviewImpl"),
|
||||
Online3D("online3DFilePreviewImpl"),
|
||||
XMIND("xmindFilePreviewImpl"),
|
||||
SVG("svgFilePreviewImpl"),
|
||||
Epub("epubFilePreviewImpl");
|
||||
|
||||
private static final String[] OFFICE_TYPES = {"docx", "wps", "doc", "docm", "xls", "xlsx", "csv" ,"xlsm", "ppt", "pptx", "vsd", "rtf", "odt", "wmf", "emf", "dps", "et", "ods", "ots", "tsv", "odp", "otp", "sxi", "ott", "vsdx", "fodt", "fods", "xltx","tga","psd"};
|
||||
private static final String[] PICTURE_TYPES = {"jpg", "jpeg", "png", "gif", "bmp", "ico", "jfif", "webp"};
|
||||
private static final String[] ARCHIVE_TYPES = {"rar", "zip", "jar", "7-zip", "tar", "gzip", "7z"};
|
||||
private static final String[] Online3D_TYPES = {"obj", "3ds", "stl", "ply", "off", "3dm", "fbx", "dae", "wrl", "3mf", "ifc","glb","o3dv","gltf","stp","bim","fcstd","step","iges","brep"};
|
||||
private static final String[] EML_TYPES = {"eml"};
|
||||
private static final String[] XMIND_TYPES = {"xmind"};
|
||||
private static final String[] Epub_TYPES = {"epub"};
|
||||
private static final String[] TIFF_TYPES = {"tif", "tiff"};
|
||||
private static final String[] OFD_TYPES = {"ofd"};
|
||||
private static final String[] SVG_TYPES = {"svg"};
|
||||
@ -74,6 +82,18 @@ public enum FileType {
|
||||
for (String svg : SVG_TYPES) {
|
||||
FILE_TYPE_MAPPER.put(svg, FileType.SVG);
|
||||
}
|
||||
for (String epub : Epub_TYPES) {
|
||||
FILE_TYPE_MAPPER.put(epub, FileType.Epub);
|
||||
}
|
||||
for (String eml : EML_TYPES) {
|
||||
FILE_TYPE_MAPPER.put(eml, FileType.EML);
|
||||
}
|
||||
for (String xmind : XMIND_TYPES) {
|
||||
FILE_TYPE_MAPPER.put(xmind, FileType.XMIND);
|
||||
}
|
||||
for (String online3D : Online3D_TYPES) {
|
||||
FILE_TYPE_MAPPER.put(online3D, FileType.Online3D);
|
||||
}
|
||||
FILE_TYPE_MAPPER.put("md", FileType.MARKDOWN);
|
||||
FILE_TYPE_MAPPER.put("xml", FileType.XML);
|
||||
FILE_TYPE_MAPPER.put("pdf", FileType.PDF);
|
||||
|
||||
@ -112,7 +112,7 @@ public class CompressFileReader {
|
||||
//去除字符串中的空格 制表符 换行 回车
|
||||
Pattern p = Pattern.compile("\\s*|\t*|\r*|\n*");
|
||||
Matcher m = p.matcher(strName);
|
||||
String after = m.replaceAll("");
|
||||
String after = m.replaceAll("").replaceAll("\\+", "").replaceAll("#", "").replaceAll("&", "");
|
||||
//去除字符串中的标点符号
|
||||
String temp = after.replaceAll("\\p{P}", "");
|
||||
//处理之后转换成字符数组
|
||||
|
||||
@ -151,7 +151,7 @@ public class FileHandlerService {
|
||||
// 添加sheet控制头
|
||||
sb.append("<script src=\"js/jquery-3.6.1.min.js\" type=\"text/javascript\"></script>");
|
||||
sb.append("<script src=\"js/excel.header.js\" type=\"text/javascript\"></script>");
|
||||
sb.append("<link rel=\"stylesheet\" href=\"bootstrap/css/bootstrap.min.css\">");
|
||||
sb.append("<link rel=\"stylesheet\" href=\"bootstrap/css/xlsx.css\">");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -273,10 +273,16 @@ public class FileHandlerService {
|
||||
if (url.contains("?fileKey=")) {
|
||||
attribute.setSkipDownLoad(true);
|
||||
}
|
||||
String urlStrr = url.toLowerCase(); //转换为小写对比
|
||||
boolean wjl = WebUtils.kuayu("&fullfilename=", urlStrr); //判断是否启用文件流
|
||||
if(wjl){
|
||||
url = url.substring(0,url.lastIndexOf("&")); //删除添加的文件流内容
|
||||
}
|
||||
url = WebUtils.encodeUrlFileName(url);
|
||||
fileName = KkFileUtils.htmlEscape(fileName); //文件名处理
|
||||
attribute.setType(type);
|
||||
attribute.setName(fileName);
|
||||
attribute.setSuffix(suffix);
|
||||
url = WebUtils.encodeUrlFileName(url);
|
||||
attribute.setUrl(url);
|
||||
if (req != null) {
|
||||
String officePreviewType = req.getParameter("officePreviewType");
|
||||
|
||||
@ -18,6 +18,10 @@ public interface FilePreview {
|
||||
String TIFF_FILE_PREVIEW_PAGE = "tiff";
|
||||
String OFD_FILE_PREVIEW_PAGE = "ofd";
|
||||
String SVG_FILE_PREVIEW_PAGE = "svg";
|
||||
String Online3D_FILE_PAGE = "online3D";
|
||||
String EpubFilePreviewImpl = "epub";
|
||||
String XMIND_FILE_PREVIEW_PAGE = "xmind";
|
||||
String EML_FILE_PREVIEW_PAGE = "eml";
|
||||
String OFFICE_PICTURE_FILE_PREVIEW_PAGE = "officePicture";
|
||||
String TXT_FILE_PREVIEW_PAGE = "txt";
|
||||
String CODE_FILE_PREVIEW_PAGE = "code";
|
||||
|
||||
@ -31,8 +31,7 @@ public class CompressFilePreviewImpl implements FilePreview {
|
||||
@Override
|
||||
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
||||
String fileName=fileAttribute.getName();
|
||||
String suffix=fileAttribute.getSuffix();
|
||||
String fileTree = null;
|
||||
String fileTree;
|
||||
// 判断文件名是否存在(redis缓存读取)
|
||||
if (!StringUtils.hasText(fileHandlerService.getConvertedFile(fileName)) || !ConfigConstants.isCacheEnabled()) {
|
||||
ReturnResponse<String> response = DownloadUtils.downLoad(fileAttribute, fileName);
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
package cn.keking.service.impl;
|
||||
|
||||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.service.FilePreview;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
/**
|
||||
* EML 文件处理
|
||||
*/
|
||||
@Service
|
||||
public class EmlFilePreviewImpl implements FilePreview {
|
||||
|
||||
private final PictureFilePreviewImpl pictureFilePreview;
|
||||
|
||||
public EmlFilePreviewImpl(PictureFilePreviewImpl pictureFilePreview) {
|
||||
this.pictureFilePreview = pictureFilePreview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
||||
pictureFilePreview.filePreviewHandle(url,model,fileAttribute);
|
||||
return EML_FILE_PREVIEW_PAGE;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.keking.service.impl;
|
||||
|
||||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.service.FilePreview;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
/**
|
||||
* svg 图片文件处理
|
||||
* @author kl (http://kailing.pub)
|
||||
* @since 2021/2/8
|
||||
*/
|
||||
@Service
|
||||
public class EpubFilePreviewImpl implements FilePreview {
|
||||
|
||||
private final PictureFilePreviewImpl pictureFilePreview;
|
||||
|
||||
public EpubFilePreviewImpl(PictureFilePreviewImpl pictureFilePreview) {
|
||||
this.pictureFilePreview = pictureFilePreview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
||||
pictureFilePreview.filePreviewHandle(url,model,fileAttribute);
|
||||
return EpubFilePreviewImpl;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.keking.service.impl;
|
||||
|
||||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.service.FilePreview;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
/**
|
||||
* Created by kl on 2018/1/17.
|
||||
* Content :图片文件处理
|
||||
*/
|
||||
@Service
|
||||
public class Online3DFilePreviewImpl implements FilePreview {
|
||||
|
||||
private final PictureFilePreviewImpl pictureFilePreview;
|
||||
|
||||
public Online3DFilePreviewImpl(PictureFilePreviewImpl pictureFilePreview) {
|
||||
this.pictureFilePreview = pictureFilePreview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
||||
pictureFilePreview.filePreviewHandle(url,model,fileAttribute);
|
||||
return Online3D_FILE_PAGE;
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ import cn.keking.service.FileHandlerService;
|
||||
import cn.keking.service.FilePreview;
|
||||
import cn.keking.utils.DownloadUtils;
|
||||
import cn.keking.utils.EncodingDetects;
|
||||
import cn.keking.utils.KkFileUtils;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.Model;
|
||||
@ -14,8 +15,6 @@ import org.springframework.web.util.HtmlUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* Created by kl on 2018/1/17.
|
||||
@ -46,7 +45,7 @@ public class SimTextFilePreviewImpl implements FilePreview {
|
||||
fileHandlerService.addConvertedFile(fileName, filePath); //加入缓存
|
||||
}
|
||||
try {
|
||||
String fileData = HtmlUtils.htmlEscape(textData(filePath));
|
||||
String fileData = HtmlUtils.htmlEscape(textData(filePath,fileName));
|
||||
model.addAttribute("textData", Base64.encodeBase64String(fileData.getBytes()));
|
||||
} catch (IOException e) {
|
||||
return otherFilePreview.notSupportedFile(model, fileAttribute, e.getLocalizedMessage());
|
||||
@ -55,7 +54,7 @@ public class SimTextFilePreviewImpl implements FilePreview {
|
||||
}
|
||||
String fileData = null;
|
||||
try {
|
||||
fileData = HtmlUtils.htmlEscape(textData(filePath));
|
||||
fileData = HtmlUtils.htmlEscape(textData(filePath,fileName));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -63,8 +62,11 @@ public class SimTextFilePreviewImpl implements FilePreview {
|
||||
return TXT_FILE_PREVIEW_PAGE;
|
||||
}
|
||||
|
||||
private String textData(String filePath) throws IOException {
|
||||
private String textData(String filePath,String fileName) throws IOException {
|
||||
File file = new File(filePath);
|
||||
if (KkFileUtils.isIllegalFileName(fileName)) {
|
||||
return null;
|
||||
}
|
||||
if (!file.exists() || file.length() == 0) {
|
||||
return "";
|
||||
} else {
|
||||
@ -72,15 +74,14 @@ public class SimTextFilePreviewImpl implements FilePreview {
|
||||
if ("ASCII".equals(charset)) {
|
||||
charset = StandardCharsets.US_ASCII.name();
|
||||
}
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(filePath)), charset));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath), charset));
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
result.append(line).append("\r\n");
|
||||
}
|
||||
br.close();
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.keking.service.impl;
|
||||
|
||||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.service.FilePreview;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
/**
|
||||
* svg 图片文件处理
|
||||
* @author kl (http://kailing.pub)
|
||||
* @since 2021/2/8
|
||||
*/
|
||||
@Service
|
||||
public class XmindFilePreviewImpl implements FilePreview {
|
||||
|
||||
private final PictureFilePreviewImpl pictureFilePreview;
|
||||
|
||||
public XmindFilePreviewImpl(PictureFilePreviewImpl pictureFilePreview) {
|
||||
this.pictureFilePreview = pictureFilePreview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
||||
pictureFilePreview.filePreviewHandle(url,model,fileAttribute);
|
||||
return XMIND_FILE_PREVIEW_PAGE;
|
||||
}
|
||||
}
|
||||
@ -3,10 +3,13 @@ package cn.keking.utils;
|
||||
import cn.keking.config.ConfigConstants;
|
||||
import cn.keking.model.FileAttribute;
|
||||
import cn.keking.model.ReturnResponse;
|
||||
import cn.keking.service.FileHandlerService;
|
||||
import io.mola.galimatias.GalimatiasParseException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
@ -35,6 +38,12 @@ public class DownloadUtils {
|
||||
String urlStr = fileAttribute.getUrl().replaceAll("\\+", "%20");
|
||||
ReturnResponse<String> response = new ReturnResponse<>(0, "下载成功!!!", "");
|
||||
String realPath = DownloadUtils.getRelFilePath(fileName, fileAttribute);
|
||||
if(!StringUtils.hasText(realPath)){
|
||||
response.setCode(1);
|
||||
response.setContent(null);
|
||||
response.setMsg("下载失败:文件名不合法!" + urlStr);
|
||||
return response;
|
||||
}
|
||||
try {
|
||||
URL url = WebUtils.normalizedURL(urlStr);
|
||||
if (!fileAttribute.getSkipDownLoad()) {
|
||||
@ -82,18 +91,20 @@ public class DownloadUtils {
|
||||
} else { // 文件后缀不一致时,以type为准(针对simText【将类txt文件转为txt】)
|
||||
fileName = fileName.replace(fileName.substring(fileName.lastIndexOf(".") + 1), type);
|
||||
}
|
||||
// 判断是否非法地址
|
||||
if (KkFileUtils.isIllegalFileName(fileName)) {
|
||||
return null;
|
||||
}
|
||||
String realPath = fileDir + fileName;
|
||||
File dirFile = new File(fileDir);
|
||||
if (!dirFile.exists() && !dirFile.mkdirs()) {
|
||||
logger.error("创建目录【{}】失败,可能是权限不够,请检查", fileDir);
|
||||
}
|
||||
|
||||
// 文件已在本地存在,跳过文件下载
|
||||
File realFile = new File(realPath);
|
||||
if (realFile.exists()) {
|
||||
fileAttribute.setSkipDownLoad(true);
|
||||
}
|
||||
|
||||
return realPath;
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
package cn.keking.utils;
|
||||
|
||||
import cpdetector.CharsetPrinter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -45,7 +43,18 @@ public class KkFileUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否是数字
|
||||
* @param str 文件名
|
||||
* @return 合规结果,true:不合规,false:合规
|
||||
*/
|
||||
public static boolean isInteger(String str) {
|
||||
if(StringUtils.hasText(str)){
|
||||
boolean strResult = str.matches("-?[0-9]+.?[0-9]*");
|
||||
return strResult ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 判断url是否是http资源
|
||||
*
|
||||
@ -89,41 +98,16 @@ public class KkFileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测文件编码格式
|
||||
*
|
||||
* @param filePath 绝对路径
|
||||
* @return 编码格式
|
||||
*/
|
||||
public static String getFileEncode(String filePath) {
|
||||
return getFileEncode(new File(filePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测文件编码格式
|
||||
*
|
||||
* @param file 检测的文件
|
||||
* @return 编码格式
|
||||
*/
|
||||
public static String getFileEncode(File file) {
|
||||
CharsetPrinter cp = new CharsetPrinter();
|
||||
try {
|
||||
String encoding = cp.guessEncoding(file);
|
||||
LOGGER.info("检测到文件【{}】编码: {}", file.getAbsolutePath(), encoding);
|
||||
return encoding;
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("文件编码获取失败,采用默认的编码格式:UTF-8", e);
|
||||
return DEFAULT_FILE_ENCODING;
|
||||
}
|
||||
}
|
||||
|
||||
public static String htmlEscape(String input) {
|
||||
if(StringUtils.hasText(input)){
|
||||
//input = input.replaceAll("\\{", "%7B").replaceAll("}", "%7D").replaceAll("\\\\", "%5C");
|
||||
return HtmlUtils.htmlEscape(input);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过文件名获取文件后缀
|
||||
*
|
||||
|
||||
@ -8,12 +8,13 @@ import javax.servlet.ServletRequest;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author : kl
|
||||
@ -173,7 +174,23 @@ public class WebUtils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断地址是否正确
|
||||
* 高 2022/12/17
|
||||
*/
|
||||
public static boolean hefaurl (String url) {
|
||||
String regStr = "^((https|http|ftp|rtsp|mms|file)://)";//[.?*]表示匹配的就是本身
|
||||
Pattern pattern = Pattern.compile(regStr);
|
||||
Matcher matcher = pattern.matcher(url);
|
||||
return matcher.find();
|
||||
}
|
||||
public static boolean kuayu(String host, String wjl) { //查询域名是否相同
|
||||
if (wjl.contains(host)) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 将 Base64 字符串解码,再解码URL参数, 默认使用 UTF-8
|
||||
* @param source 原始 Base64 字符串
|
||||
@ -183,11 +200,10 @@ public class WebUtils {
|
||||
*/
|
||||
public static String decodeUrl(String source) {
|
||||
String url = decodeBase64String(source, StandardCharsets.UTF_8);
|
||||
try {
|
||||
url = URLDecoder.decode(url, StandardCharsets.UTF_8.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
if (! StringUtils.isNotBlank(url)){
|
||||
return null;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
@ -203,9 +219,13 @@ public class WebUtils {
|
||||
* 有些 Base64 实现可能每 76 个字符插入换行符,也一并去掉
|
||||
* https://github.com/kekingcn/kkFileView/pull/340
|
||||
*/
|
||||
return new String(Base64Utils.decodeFromString(
|
||||
source.replaceAll(" ", "+").replaceAll("\n", "")
|
||||
), charsets);
|
||||
try {
|
||||
return new String(Base64Utils.decodeFromString(source.replaceAll(" ", "+").replaceAll("\n", "")), charsets);
|
||||
} catch (Exception e) {
|
||||
System.out.println("接入方法错误,或者未使用BASE64");
|
||||
// e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -46,26 +46,45 @@ public class AttributeSetFilter implements Filter {
|
||||
* 设置水印属性
|
||||
* @param request request
|
||||
*/
|
||||
|
||||
private void setWatermarkAttribute(ServletRequest request) {
|
||||
String watermarkTxt= KkFileUtils.htmlEscape(request.getParameter("watermarkTxt"));
|
||||
request.setAttribute("watermarkTxt", watermarkTxt != null ? watermarkTxt : WatermarkConfigConstants.getWatermarkTxt());
|
||||
String watermarkXSpace = request.getParameter("watermarkXSpace");
|
||||
String watermarkXSpace = KkFileUtils.htmlEscape(request.getParameter("watermarkXSpace"));
|
||||
if (!KkFileUtils.isInteger(watermarkXSpace)){
|
||||
watermarkXSpace =null;
|
||||
}
|
||||
request.setAttribute("watermarkXSpace", watermarkXSpace != null ? watermarkXSpace : WatermarkConfigConstants.getWatermarkXSpace());
|
||||
String watermarkYSpace = request.getParameter("watermarkYSpace");
|
||||
String watermarkYSpace = KkFileUtils.htmlEscape(request.getParameter("watermarkYSpace"));
|
||||
if (!KkFileUtils.isInteger(watermarkYSpace)){
|
||||
watermarkYSpace =null;
|
||||
}
|
||||
request.setAttribute("watermarkYSpace", watermarkYSpace != null ? watermarkYSpace : WatermarkConfigConstants.getWatermarkYSpace());
|
||||
String watermarkFont = request.getParameter("watermarkFont");
|
||||
String watermarkFont = KkFileUtils.htmlEscape(request.getParameter("watermarkFont"));
|
||||
request.setAttribute("watermarkFont", watermarkFont != null ? watermarkFont : WatermarkConfigConstants.getWatermarkFont());
|
||||
String watermarkFontsize = request.getParameter("watermarkFontsize");
|
||||
String watermarkFontsize = KkFileUtils.htmlEscape(request.getParameter("watermarkFontsize"));
|
||||
request.setAttribute("watermarkFontsize", watermarkFontsize != null ? watermarkFontsize : WatermarkConfigConstants.getWatermarkFontsize());
|
||||
String watermarkColor = request.getParameter("watermarkColor");
|
||||
String watermarkColor = KkFileUtils.htmlEscape(request.getParameter("watermarkColor"));
|
||||
request.setAttribute("watermarkColor", watermarkColor != null ? watermarkColor : WatermarkConfigConstants.getWatermarkColor());
|
||||
String watermarkAlpha = request.getParameter("watermarkAlpha");
|
||||
String watermarkAlpha = KkFileUtils.htmlEscape(request.getParameter("watermarkAlpha"));
|
||||
if (!KkFileUtils.isInteger(watermarkAlpha)){
|
||||
watermarkAlpha =null;
|
||||
}
|
||||
request.setAttribute("watermarkAlpha", watermarkAlpha != null ? watermarkAlpha : WatermarkConfigConstants.getWatermarkAlpha());
|
||||
String watermarkWidth = request.getParameter("watermarkWidth");
|
||||
String watermarkWidth = KkFileUtils.htmlEscape(request.getParameter("watermarkWidth"));
|
||||
if (!KkFileUtils.isInteger(watermarkWidth)){
|
||||
watermarkWidth =null;
|
||||
}
|
||||
request.setAttribute("watermarkWidth", watermarkWidth != null ? watermarkWidth : WatermarkConfigConstants.getWatermarkWidth());
|
||||
String watermarkHeight = request.getParameter("watermarkHeight");
|
||||
String watermarkHeight = KkFileUtils.htmlEscape(request.getParameter("watermarkHeight"));
|
||||
if (!KkFileUtils.isInteger(watermarkHeight)){
|
||||
watermarkHeight =null;
|
||||
}
|
||||
request.setAttribute("watermarkHeight", watermarkHeight != null ? watermarkHeight : WatermarkConfigConstants.getWatermarkHeight());
|
||||
String watermarkAngle = request.getParameter("watermarkAngle");
|
||||
String watermarkAngle = KkFileUtils.htmlEscape(request.getParameter("watermarkAngle"));
|
||||
if (!KkFileUtils.isInteger(watermarkAngle)){
|
||||
watermarkAngle =null;
|
||||
}
|
||||
request.setAttribute("watermarkAngle", watermarkAngle != null ? watermarkAngle : WatermarkConfigConstants.getWatermarkAngle());
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ public class TrustDirFilter implements Filter {
|
||||
}
|
||||
|
||||
private boolean allowPreview(String urlPath) {
|
||||
if(!StringUtils.hasText(urlPath)){
|
||||
if(!StringUtils.hasText(urlPath) || !WebUtils.hefaurl(urlPath)){ //判断URL是否合法
|
||||
return false ;
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user