mirror of
https://gitee.com/wangkang/udf.git
synced 2026-10-21 17:35:10 +00:00
去除objectmapper的特殊字符过滤
This commit is contained in:
+3
-3
@@ -39,12 +39,12 @@ public class RabbitMqConfig {
|
||||
/**
|
||||
* 描述 : jackson2JsonMessageConverter
|
||||
*
|
||||
* @param xssObjectMapper xssObjectMapper
|
||||
* @param objectMapper objectMapper
|
||||
* @return jackson2JsonMessageConverter
|
||||
*/
|
||||
@Bean
|
||||
public Jackson2JsonMessageConverter jackson2JsonMessageConverter(ObjectMapper xssObjectMapper) {
|
||||
return new Jackson2JsonMessageConverter(xssObjectMapper);
|
||||
public Jackson2JsonMessageConverter jackson2JsonMessageConverter(ObjectMapper objectMapper) {
|
||||
return new Jackson2JsonMessageConverter(objectMapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,18 +6,13 @@
|
||||
*/
|
||||
package org.itkk.udf.core;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import org.itkk.udf.core.xss.XssStringJsonSerializer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
import org.springframework.retry.annotation.EnableRetry;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@@ -42,25 +37,6 @@ public class BaseApplication {
|
||||
@Autowired
|
||||
private ApplicationConfig applicationConfig;
|
||||
|
||||
/**
|
||||
* 描述 : xssObjectMapper
|
||||
*
|
||||
* @param builder builder
|
||||
* @return xssObjectMapper
|
||||
*/
|
||||
@Bean
|
||||
@Primary
|
||||
public ObjectMapper xssObjectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||
//解析器
|
||||
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
||||
//注册xss解析器
|
||||
SimpleModule xssModule = new SimpleModule("XssStringJsonSerializer");
|
||||
xssModule.addSerializer(new XssStringJsonSerializer());
|
||||
objectMapper.registerModule(xssModule);
|
||||
//返回
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 描述 : externalRestTemplate
|
||||
*
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* XssStringJsonSerializer.java
|
||||
* Created at 2016-09-19
|
||||
* Created by wangkang
|
||||
* Copyright (C) 2016 itkk.org, All rights reserved.
|
||||
*/
|
||||
package org.itkk.udf.core.xss;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 描述 : 基于xss的JsonSerializer
|
||||
*
|
||||
* @author wangkang
|
||||
*/
|
||||
public class XssStringJsonSerializer extends JsonSerializer<String> {
|
||||
|
||||
@Override
|
||||
public Class<String> handledType() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(String value, JsonGenerator jsonGenerator,
|
||||
SerializerProvider serializerProvider) throws IOException {
|
||||
if (value != null) {
|
||||
String encodedValue = HtmlUtils.htmlEscape(value);
|
||||
jsonGenerator.writeString(encodedValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-2
@@ -23,7 +23,6 @@ import java.util.Map;
|
||||
* 描述 : AutoInitCommandLineRunner
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class AutoInitCommandLineRunner implements CommandLineRunner {
|
||||
@@ -62,7 +61,7 @@ public class AutoInitCommandLineRunner implements CommandLineRunner {
|
||||
}
|
||||
//自动实例化SimpleTrigger
|
||||
Map<String, SimpleTriggerMeta> simpleTriggerMetaMap =
|
||||
schedulerProperties.getSimpleTrigger();
|
||||
schedulerProperties.getSimpleTrigger();
|
||||
if (MapUtils.isNotEmpty(simpleTriggerMetaMap)) {
|
||||
Iterator<String> simpleTriggerMetaKeys = simpleTriggerMetaMap.keySet().iterator();
|
||||
while (simpleTriggerMetaKeys.hasNext()) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class TriggerMeta implements Serializable {
|
||||
/**
|
||||
* 描述 : 开始时间
|
||||
*/
|
||||
private Date startTime = new Date();
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 描述 : 结束时间
|
||||
|
||||
Reference in New Issue
Block a user