'Does chaining filter_input() and filter_var() cause the problem?

I have this url for testing

http://localhost:8000/2.php?site=https://google.com<script></script>

Then I am sanitizing "site":

$site = filter_input(INPUT_GET, 'site', FILTER_SANITIZE_URL);
var_dump($site); // string(35) "https://google.com"
echo "<br>";

Getting absolutely safe url. Then validating it:

$siteValidation = filter_var($site, FILTER_VALIDATE_URL);
var_dump($siteValidation); // bool(false)

And validation fails! Why?

enter image description here



Solution 1:[1]

you can use this package (material_floating_search_bar) to obtain this behavior.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Felipe Vergara