What potential pitfalls should PHP developers be aware of when using window.open() for pop-up windows?

When using window.open() for pop-up windows in PHP, developers should be aware of potential security risks such as cross-site scripting attacks. To mitigate this risk, developers should ensure that the URL being passed to window.open() is properly validated and sanitized to prevent malicious code injection.

$url = filter_var($_GET['url'], FILTER_VALIDATE_URL);
if($url){
    echo "<script>window.open('$url');</script>";
} else {
    echo "Invalid URL";
}