1
0
mirror of synced 2025-12-25 03:47:55 +08:00

🐛 #3348 【公共问题】修复无法获取正确文件名的问题

This commit is contained in:
Binary Wang
2024-08-20 11:39:54 +08:00
parent b6a8721bd1
commit 748c19f108
2 changed files with 55 additions and 10 deletions

View File

@@ -0,0 +1,26 @@
package me.chanjar.weixin.common.util.http;
import me.chanjar.weixin.common.error.WxErrorException;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
public class HttpResponseProxyTest {
@Test
public void testExtractFileNameFromContentString() throws WxErrorException {
String content = "attachment; filename*=utf-8''%E6%B5%8B%E8%AF%95.xlsx; filename=\"æµ<EFBFBD>è¯<EFBFBD>.xlsx\"";
String filename = HttpResponseProxy.extractFileNameFromContentString(content);
assertNotNull(filename);
assertEquals(filename, "测试.xlsx");
}
@Test
public void testExtractFileNameFromContentString_another() throws WxErrorException {
String content = "attachment; filename*=utf-8''%E8%90%A5%E4%B8%9A%E6%89%A7%E7%85%A7.jpg; filename=\"è<EFBFBD>¥ä¸<EFBFBD>æ<EFBFBD>§ç<EFBFBD>§.jpg\"";
// String content = "attachment; filename=\"è<>¥ä¸<C3A4>æ<EFBFBD>§ç<C2A7>§.jpg\"";
String filename = HttpResponseProxy.extractFileNameFromContentString(content);
assertNotNull(filename);
assertEquals(filename, "营业执照.jpg");
}
}