What are some potential pitfalls or security concerns when using parse_url in PHP for URL processing?

One potential pitfall when using parse_url in PHP for URL processing is that it may not handle all possible URL formats, leading to unexpected behavior or security vulnerabilities. To mitigate this risk, it is recommended to validate the URL before processing it further.

$url = $_GET['url'];

if (filter_var($url, FILTER_VALIDATE_URL)) {
    $parsed_url = parse_url($url);
    // Further processing of the parsed URL
} else {
    // Handle invalid URL input
}