rspec/rules/S5145/java/rule.adoc
2022-02-04 16:28:24 +00:00

41 lines
881 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
[source,java]
----
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String param1 = req.getParameter("param1");
Logger.info("Param1: " + param1 + " " + Logger.getName()); // Noncompliant
// ...
}
----
== Compliant Solution
[source,java]
----
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String param1 = req.getParameter("param1");
// Replace pattern-breaking characters
param1 = param1.replaceAll("[\n\r\t]", "_");
Logger.info("Param1: " + param1 + " " + Logger.getName());
// ...
}
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
endif::env-github,rspecator-view[]