Skip to content

Commit

Permalink
Update coding example
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource committed Dec 9, 2024
1 parent 2ececbd commit b0c4613
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions rules/S6932/csharp/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,6 @@ public ActionResult Post()
var cultureName = Request.QueryString["locale"] ?? "en-US"; // Noncompliant: Request.QueryString
// ..
}
public IActionResult Post()
{
var origin = Request.Headers[HeaderNames.Origin]; // Compliant: Access via variable
var name = Request.Form["name"]; // Compliant: Access via constant and variable keys is mixed
var birthdate = DateTime.Parse(Request.Form["Birthdate"]); // Compliant: Access via constant and variable keys is mixed
// ..
}
----

==== Compliant solution
Expand All @@ -170,6 +162,14 @@ public ActionResult Post(User user, [Bind(Prefix = "locale")] string cultureName
// ...
}
}
public IActionResult Post()
{
var origin = Request.Headers[HeaderNames.Origin]; // Compliant: Access via variable
var name = Request.Form["name"]; // Compliant: Access via constant and variable keys is mixed
var birthdate = DateTime.Parse(Request.Form["Birthdate"]); // Compliant: Access via constant and variable keys is mixed
// ..
}
----

include::../how-does-this-work.adoc[]
Expand Down

0 comments on commit b0c4613

Please sign in to comment.