42 lines
648 B
Plaintext
42 lines
648 B
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,php]
|
|
----
|
|
$url = $_GET["url"];
|
|
$resp = file_get_contents($url); // Noncompliant
|
|
// ...
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
[source,php]
|
|
----
|
|
$whitelist = array(
|
|
"www.example.com",
|
|
"example.com"
|
|
);
|
|
|
|
$url = $_GET["url"];
|
|
$parsed_url = parse_url($url);
|
|
|
|
if (in_array($parsed_url['host'], $whitelist)) {
|
|
$resp = file_get_contents($url);
|
|
// ...
|
|
}
|
|
----
|
|
|
|
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[]
|