Avoid request params access for form data in logRequest
Close gh-28587
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -978,7 +978,8 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
private void logRequest(HttpServletRequest request) {
|
||||
LogFormatUtils.traceDebug(logger, traceOn -> {
|
||||
String params;
|
||||
if (StringUtils.startsWithIgnoreCase(request.getContentType(), "multipart/")) {
|
||||
String contentType = request.getContentType();
|
||||
if (StringUtils.startsWithIgnoreCase(contentType, "multipart/")) {
|
||||
params = "multipart";
|
||||
}
|
||||
else if (isEnableLoggingRequestDetails()) {
|
||||
@@ -987,7 +988,9 @@ public class DispatcherServlet extends FrameworkServlet {
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
else {
|
||||
params = (request.getParameterMap().isEmpty() ? "" : "masked");
|
||||
// Avoid request body parsing for form data
|
||||
params = (StringUtils.startsWithIgnoreCase(contentType, "application/x-www-form-urlencoded") ||
|
||||
!request.getParameterMap().isEmpty() ? "masked" : "");
|
||||
}
|
||||
|
||||
String queryString = request.getQueryString();
|
||||
|
||||
Reference in New Issue
Block a user