2020-06-30 12:50:28 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
|
|
|
String param1 = req.getParameter("param1");
|
|
|
|
Logger.info("Param1: " + param1 + " " + Logger.getName()); // Noncompliant
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
|
|
|
----
|
|
|
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
|
|
|
String param1 = req.getParameter("param1");
|
|
|
|
|
|
|
|
// Replace pattern-breaking characters
|
2021-04-26 17:29:13 +02:00
|
|
|
param1 = param1.replaceAll("[\n\r\t]", "_");
|
2020-06-30 12:50:28 +02:00
|
|
|
|
|
|
|
Logger.info("Param1: " + param1 + " " + Logger.getName());
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
include::../see.adoc[]
|