Remove password protected posts from default RSS feed

Here’s the filter to exclude password protected posts from the default RSS feed:

function rss_filter_protected( $query ) {
    if ( $query->is_feed ) {
        $query->set( 'has_password', false );
    }
    return $query;
}
add_filter( 'pre_get_posts','rss_filter_protected' );