/home/techb158/public_html/wp-content/plugins/wpforms-lite/src/Admin
NameSizeModeActions
Addons/-0755rm
Base/-0755rm
Blocks/-0755rm
Builder/-0755rm
Dashboard/-0755rm
Education/-0755rm
Forms/-0755rm
Helpers/-0755rm
Notifications/-0755rm
Pages/-0755rm
Payments/-0755rm
Settings/-0755rm
Splash/-0755rm
Tools/-0755rm
Traits/-0755rm
AdminBarMenu.php183640666editdlrm
Challenge.php180310666editdlrm
FlyoutMenu.php35910666editdlrm
FormEmbedWizard.php167100666editdlrm
Loader.php16920666editdlrm
MediaLibrary.php34420666editdlrm
Notice.php100820666editdlrm
PluginsCategory.php55140666editdlrm
Revisions.php129580666editdlrm
SiteHealth.php28370666editdlrm
Edit: /home/techb158/public_html/wp-content/plugins/wpforms-lite/src/Admin/MediaLibrary.php (3442B)
hooks(); } /** * Register hooks. * * @since 1.10.2 */ private function hooks(): void { add_filter( 'wp_handle_upload_prefilter', [ $this, 'sanitize_svg_upload' ] ); } /** * Sanitize an SVG being uploaded to the media library from a WPForms admin context. * * Reuses wpforms_sanitize_svg_file(): non-SVG files are untouched, and the upload is * rejected when an SVG cannot be sanitized (e.g. gzipped .svgz or invalid XML), mirroring * the File Upload field behavior. * * @since 1.10.2 * * @param array|mixed $file Array of a single uploaded file ( name, type, tmp_name, error, size ). * * @return array Modified file array. */ public function sanitize_svg_upload( $file ): array { $file = (array) $file; // Preserve any pre-existing upload error ( e.g. file too large, failed PHP upload ). if ( ! empty( $file['error'] ) ) { return $file; } // Only act on SVG uploads; everything else passes through untouched. if ( empty( $file['name'] ) || ! $this->is_svg( (string) $file['name'] ) ) { return $file; } // Limit to uploads originating from WPForms admin to avoid touching unrelated SVGs. if ( ! $this->is_wpforms_upload() ) { return $file; } if ( empty( $file['tmp_name'] ) || ! wpforms_sanitize_svg_file( $file['tmp_name'], (string) $file['name'] ) ) { $file['error'] = esc_html__( 'Sorry, this SVG file could not be sanitized, so it was not uploaded.', 'wpforms-lite' ); } return $file; } /** * Whether the file name points to an SVG ( or gzipped SVG ). * * @since 1.10.2 * * @param string $file_name Uploaded file name. * * @return bool */ private function is_svg( string $file_name ): bool { $extension = strtolower( pathinfo( $file_name, PATHINFO_EXTENSION ) ); return in_array( $extension, [ 'svg', 'svgz' ], true ); } /** * Whether the current upload request originates from a WPForms admin context. * * Detected either by the `wpforms-` post_id marker ( Rich Text field convention ) or by a * referer pointing to a WPForms admin page. Nonce and capability are already verified upstream * by WordPress core ( wp_ajax_upload_attachment ), so this only reads request context for routing. * * @since 1.10.2 * * @return bool */ private function is_wpforms_upload(): bool { // phpcs:disable WordPress.Security.NonceVerification.Missing $post_id = isset( $_POST['post_id'] ) ? sanitize_text_field( wp_unslash( $_POST['post_id'] ) ) : ''; // phpcs:enable WordPress.Security.NonceVerification.Missing if ( strpos( $post_id, 'wpforms-' ) === 0 ) { return true; } $referer = wp_get_referer(); if ( ! $referer ) { return false; } $query = (string) wp_parse_url( $referer, PHP_URL_QUERY ); wp_parse_str( $query, $args ); $page = isset( $args['page'] ) ? (string) $args['page'] : ''; return strpos( $page, 'wpforms' ) === 0; } }