//
// Create a new configuration object
$config = HTMLPurifier_Config::createDefault();
$config->set('Filter.ExtractStyleBlocks', true);
$config->set('CSS.AllowImportant', true);
$config->set('CSS.AllowTricky', true);
$config->set('CSS.Trusted', true);
$config->set('Cache.SerializerPath', base_path('storage/framework/cache'));
// Create a new purifier instance
$purifier = new HTMLPurifier($config);
// Wrap our CSS in style tags and pass to purifier.
// we're not actually interested in the html response though
$purifier->purify('');
// The "style" blocks are stored seperately
$css = $purifier->context->get('StyleBlocks');
// Get the first style block
return count($css) ? $css[0] : '';
}
public static function sanitizeHTML($html)
{
$html = html_entity_decode($html);
$config = HTMLPurifier_Config::createDefault();
$config->set('Cache.SerializerPath', base_path('storage/framework/cache'));
$purifier = new HTMLPurifier($config);
return $purifier->purify($html);
}
public static function previousUrl($fallback)
{
$previous = url()->previous();
$current = request()->url();
if ($previous == $current) {
return url($fallback);
} else {
return $previous;
}
}
}