rspec/rules/S5145/java/rule.adoc

41 lines
881 B
Plaintext
Raw Normal View History

2020-06-30 12:50:28 +02:00
include::../description.adoc[]
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,java]
2020-06-30 12:50:28 +02:00
----
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String param1 = req.getParameter("param1");
Logger.info("Param1: " + param1 + " " + Logger.getName()); // Noncompliant
// ...
}
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,java]
2020-06-30 12:50:28 +02:00
----
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String param1 = req.getParameter("param1");
// Replace pattern-breaking characters
param1 = param1.replaceAll("[\n\r\t]", "_");
2020-06-30 12:50:28 +02:00
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[]