WC_Helper_Sanitization::wc_pre_sanitize_svg
Sanitize SVG content before processing with wp_kses.
Метод класса: WC_Helper_Sanitization{}
Хуков нет.
Возвращает
string. Sanitized SVG content.
Использование
$result = WC_Helper_Sanitization::wc_pre_sanitize_svg( $content );
- $content(строка) (обязательный)
- The SVG content to sanitize.
Код WC_Helper_Sanitization::wc_pre_sanitize_svg() WC Helper Sanitization::wc pre sanitize svg WC 11.3.0
public static function wc_pre_sanitize_svg( $content ) {
// Remove any xlink:href attributes containing javascript.
$content = preg_replace( '/xlink:href\s*=\s*(["\'])\s*javascript:.*?\1/i', '', $content );
// Remove foreignObject elements (can contain arbitrary HTML).
$content = preg_replace( '/<foreignObject\b[^>]*>.*?<\/foreignObject>/is', '', $content );
return $content;
}