Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

34 lines
583 B
Plaintext

== How to fix it in Core PHP
=== Code examples
include::../../common/fix/code-rationale.adoc[]
==== Noncompliant code example
[source,php,diff-id=1,diff-type=noncompliant]
----
$url=$_GET['url'];
header("Location: " . $url); // Noncompliant
----
==== Compliant solution
[source,php,diff-id=1,diff-type=compliant]
----
$url=$_GET['url'];
$allowedUrls = ['https://example.com/'];
if(in_array($url, $allowedUrls, true)){
header("Location: " . $url);
}
----
include::../../common/fix/how-does-this-work.adoc[]
=== Pitfalls
include::../../common/pitfalls/starts-with.adoc[]