Commit f2a7a856 authored by Jakob Moser's avatar Jakob Moser
Browse files

Improve sanitization for width and height

parent e9ce7aa5
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -40,8 +40,14 @@ add_filter('upload_mimes', 'fscoli_mime_types', 1, 1);
 * https://developer.wordpress.org/reference/classes/wp_embed/get_embed_handler_html/
 */
function fscoli_embed_umap($regex_matches, $embed_attrs, $url, $raw_embed_attrs) {
    $width = esc_attr(intval($embed_attrs['width']).'px');
    $height = esc_attr(intval($embed_attrs['height']).'px');
    $width = esc_attr(
        is_numeric($embed_attrs['width']) ? $embed_attrs['width']."px" : "auto"
    );

    $height = esc_attr(
        is_numeric($embed_attrs['height']) ? $embed_attrs['height']."px" : "auto"
    );
    
    $url = esc_url($url);
    return <<<HTML
        <iframe src="$url" style="width: $width; height: $height" allow="fullscreen"></iframe>