What potential pitfalls should be considered when trying to embed a Twitch chat as an iframe in a PHP script?

One potential pitfall when embedding a Twitch chat as an iframe in a PHP script is the risk of exposing sensitive information or allowing malicious code execution. To mitigate this risk, it is important to properly sanitize and validate user input before embedding the chat iframe.

<?php
// Sanitize and validate the Twitch channel name before embedding the chat iframe
$twitch_channel = filter_var($_GET['channel'], FILTER_SANITIZE_STRING);

// Embed the Twitch chat iframe with the sanitized channel name
echo '<iframe src="https://www.twitch.tv/embed/' . $twitch_channel . '/chat" frameborder="0" scrolling="no" height="500" width="350"></iframe>';
?>