mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
修复302重定向时,Location中的问号被转义问题
This commit is contained in:
parent
713832e5fe
commit
26751fac57
@ -2,7 +2,7 @@
|
|||||||
# 🚀Changelog
|
# 🚀Changelog
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.22(2023-08-21)
|
# 5.8.22(2023-08-24)
|
||||||
|
|
||||||
### 🐣新特性
|
### 🐣新特性
|
||||||
* 【core 】 NumberUtil.nullToZero增加重载(issue#I7PPD2@Gitee)
|
* 【core 】 NumberUtil.nullToZero增加重载(issue#I7PPD2@Gitee)
|
||||||
@ -23,6 +23,7 @@
|
|||||||
* 【core 】 修复FieldsComparator比较结果不正确问题(issue#3259@Github)
|
* 【core 】 修复FieldsComparator比较结果不正确问题(issue#3259@Github)
|
||||||
* 【core 】 修复Db.findAll全局忽略大小写无效问题(issue#I7T30Y@Gitee)
|
* 【core 】 修复Db.findAll全局忽略大小写无效问题(issue#I7T30Y@Gitee)
|
||||||
* 【core 】 修复Ipv4Util.getEndIpLong 取反符号导致数据越界(issue#I7U1OQ@Gitee)
|
* 【core 】 修复Ipv4Util.getEndIpLong 取反符号导致数据越界(issue#I7U1OQ@Gitee)
|
||||||
|
* 【http 】 修复302重定向时,Location中的问号被转义问题(issue#3265@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.21(2023-07-29)
|
# 5.8.21(2023-07-29)
|
||||||
|
@ -1293,13 +1293,23 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
|||||||
final UrlBuilder redirectUrl;
|
final UrlBuilder redirectUrl;
|
||||||
String location = httpConnection.header(Header.LOCATION);
|
String location = httpConnection.header(Header.LOCATION);
|
||||||
if (false == HttpUtil.isHttp(location) && false == HttpUtil.isHttps(location)) {
|
if (false == HttpUtil.isHttp(location) && false == HttpUtil.isHttps(location)) {
|
||||||
// issue#I5TPSY
|
// issue#I5TPSY, location可能为相对路径
|
||||||
// location可能为相对路径
|
|
||||||
if (false == location.startsWith("/")) {
|
if (false == location.startsWith("/")) {
|
||||||
location = StrUtil.addSuffixIfNot(this.url.getPathStr(), "/") + location;
|
location = StrUtil.addSuffixIfNot(this.url.getPathStr(), "/") + location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// issue#3265, 相对路径中可能存在参数,单独处理参数
|
||||||
|
final String query;
|
||||||
|
final List<String> split = StrUtil.split(location, '?', 2);
|
||||||
|
if (split.size() == 2) {
|
||||||
|
// 存在参数
|
||||||
|
location = split.get(0);
|
||||||
|
query = split.get(1);
|
||||||
|
} else {
|
||||||
|
query = null;
|
||||||
|
}
|
||||||
redirectUrl = UrlBuilder.of(this.url.getScheme(), this.url.getHost(), this.url.getPort()
|
redirectUrl = UrlBuilder.of(this.url.getScheme(), this.url.getHost(), this.url.getPort()
|
||||||
, location, null, null, this.charset);
|
, location, query, null, this.charset);
|
||||||
} else {
|
} else {
|
||||||
redirectUrl = UrlBuilder.ofHttpWithoutEncode(location);
|
redirectUrl = UrlBuilder.ofHttpWithoutEncode(location);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user