Improved Simpler CSS
can crash php running under apache on windows (2 posts)

  1. James Revillini
    Posted 4 years ago #

    There is a bug in PHP that is plaguing many developers and site owners right now which pertains to processing a 'large' string with preg_replace. Something to do with the apache stack.

    Long story short: this line (improved-simpler-css.php:251) brings my site down
    $_return = preg_replace ( '/@import.+;( |)|((?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/))/i', '', $_content );

    if I replace with $_return = $_content everything is fine. I'm OK with the extra load time for now. I'm probably going to try splitting the replace statement into multiple steps.

    more info/examples: http://www.apachefriends.org/f/viewtopic.php?f=16&t=45367#p184056


  2. James Revillini
    Posted 4 years ago #

    This replacement function seems to work under XAMPP for windows. It doesn't do as much optimizing but I don't think it screws up anything.

    function improved_simpler_css_filter($_content) {
    	$_return = $_content;
    	$_return = preg_replace ( '/@import.+;/i', '', $_return ); // rem import stmts
    	$_return = preg_replace ( '/(\t|\n)/', '', $_return ); // rem tabs & linebreaks
    	$_return = preg_replace ( '#/\*.+?\*/#s', '', $_return ); // rem comments
    	$_return = htmlspecialchars ( strip_tags($_return), ENT_NOQUOTES, 'UTF-8' );
    	return $_return;

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Improved Simpler CSS
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic