Skip to content

Commit 49fe998

Browse files
Merge pull request #25 from geekidea/dev
🏇 拦截器启用禁用配置,更改core包目录,下载上传拦截器,logback.xml优化显示行号 Former-commit-id: 2a0885f4c7d38dae871e15c407b7f8b5bbf5b229
2 parents 8230fba + 34b712e commit 49fe998

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
# 更新日志 CHANGELOG
22

3+
## [V1.2.2-RELEASE] 2019.08.26 🏇
4+
### ⭐️ New Features
5+
- 拦截器启用禁用配置
6+
- 文件上传下载安全/权限控制
7+
- 启用 `logback.xml` 日志配置
8+
9+
### ⚡️ Optimization
10+
- 更改core包目录
11+
- 下载上传拦截器
12+
- logback.xml显示行号
13+
- `application.yml` 拦截器配置新增 `include-path` 拦截路径配置
14+
15+
16+
### 📝 Added/Modified
17+
- Add `UploadInterceptor` 文件上传全局拦截器
18+
- Add `DownloadInterceptor` 文件下载全局拦截器
19+
- Add `DownloadHandler` `DefaultDownloadHandler` 文件下载回调自定义处理器
20+
- Modify `config/WebMvcConfig` --> `core/SpringBootPlusWebMvcConfig`
21+
- Modify `ImageController` --> `ResouceController`,请求路径 `/api/resource`
22+
23+
24+
### 🐞 Bug Fixes
25+
- Fix 文件下载路径潜在安全漏洞,过滤 `../` 非法路径参数
26+
- Fix 优化文件下载,Firefox 中文乱码问题
27+
28+
329
## [V1.2.1-RELEASE] 2019.08.21
430

531
### ⭐️ New Features

src/main/java/io/geekidea/springbootplus/SpringBootPlusApplication.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ public static void main(String[] args) {
4747
ConfigurableApplicationContext context = SpringApplication.run(SpringBootPlusApplication.class, args);
4848
// 打印项目信息
4949
PrintApplicationInfo.print(context);
50-
/**
51-
* TODO 日志现实行号
52-
* 拦截器配置是否启用,参照文件上传拦截器
53-
*/
5450
}
5551

5652
}

src/main/java/io/geekidea/springbootplus/resource/web/controller/ResourceController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@
2828

2929
/**
3030
* 图片等文件资源访问控制器
31+
* /api/resource 访问路径 用于区分 文件访问虚拟目录映射 /resource
3132
* @author geekidea
3233
* @date 2019/8/20
3334
* @since 1.2.1-RELEASE
3435
*/
3536
@Slf4j
3637
@Controller
37-
@RequestMapping("/image")
38+
@RequestMapping("/api/resource")
3839
public class ResourceController {
3940

4041
@Autowired
@@ -43,7 +44,7 @@ public class ResourceController {
4344
/**
4445
* 访问图片
4546
*/
46-
@GetMapping("/{imageFileName}")
47+
@GetMapping("/image/{imageFileName}")
4748
@ApiOperation(value = "访问图片",notes = "访问图片",response = ApiResult.class)
4849
public void getImage(@PathVariable(required = true) String imageFileName, HttpServletResponse response) throws Exception{
4950
log.info("imageFileName:{}",imageFileName);

src/main/java/io/geekidea/springbootplus/util/DownloadUtil.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,6 @@ public static void download( String downloadDir, String downloadFileName, List<S
129129
FileCopyUtils.copy(in, response.getOutputStream());
130130
}
131131

132-
public static void main(String[] args) throws Exception {
133-
String downloadFileName = "../../hello/123.txt";
134-
// 安全判断,防止../情况
135-
if (downloadFileName.contains("..")||downloadFileName.contains("../")){
136-
throw new IOException("非法的文件名称");
137-
}
138-
log.info("ok");
139-
}
140-
141132
public static interface DownloadHandler{
142133
boolean handle(String dir, String fileName,File file,String fileExtension,String contentType,long length) throws Exception;
143134
}

0 commit comments

Comments
 (0)