Plugin Directory

Changeset 2001833


Ignore:
Timestamp:
12/26/2018 06:25:17 PM (7 years ago)
Author:
terresquall
Message:

Commit for v2.3.2.

Location:
html-minifier/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • html-minifier/trunk/html-minifier.php

    r1995957 r2001833  
    77Plugin URI: http://www.terresquall.com/web/html-minifier/
    88Description: Provides a variety of optimisation options (e.g. minification, caching, code reorganisation) for your site's source code to help meet today's web performance standards.
    9 Version: 2.3.2
    10 Dated: 07/12/2018
     9Version: 2.3.3
     10Dated: 27/12/2018
    1111Author: Terresquall
    1212Author URI: http://www.terresquall.com/
     
    2929require_once HTML_MINIFIER__PLUGIN_DIR . 'inc/HTMLMinifier.manager.php';
    3030
    31 define('HTML_MINIFIER_PLUGIN_VERSION', '2.3.2');
    32 define('HTML_MINIFIER_PLUGIN_VERSION_DATE', '17 December 2018');
     31define('HTML_MINIFIER_PLUGIN_VERSION', '2.3.3');
     32define('HTML_MINIFIER_PLUGIN_VERSION_DATE', '27 December 2018');
    3333
    3434add_action('init',array('HTMLMinifier_Manager','init'));
  • html-minifier/trunk/inc/src/HTMLMinifier.php

    r1995957 r2001833  
    99@author     Terence Pek <terence@terresquall.com>
    1010@website    www.terresquall.com
    11 @version    3.2.2
    12 @dated      17/12/2018
    13 @notes      - Fixed a critical error with the remove comments functionality in Javascript and CSS that caused some major bugs.
     11@version    3.2.3
     12@dated      27/12/2018
     13@notes      - Fixed another critical error with the remove comments functionality that caused some major bugs.
     14            - Fixed a critical error with the remove comments functionality in Javascript and CSS that caused some major bugs.
    1415            - Rewrote the remove_comments() function in HTML minifier to make it more efficient. The old function incorrectly identified regexes and strings previously, and was not efficient.
    1516            - Fixed a bug that caused 'shift_script_tags_to_bottom' to always create script tags at the end of the page.
     
    3839    public static $CacheExpiry = 86400; // Time in seconds. 86400 is 1 day.
    3940   
    40     const VERSION = '3.2.2';
     41    const VERSION = '3.2.3';
    4142    const SIGNATURE = 'Original size: %d bytes, minified: %d bytes. HTMLMinifier: www.terresquall.com/web/html-minifier.';
    4243    const CACHE_SIG = 'Server cached on %s.';
     
    10601061       
    10611062        // Encapsulated content that we want to capture (in regex without delimiters).
    1062         $encap_start = array("'",'"');
    1063         $encap_end = array("(?:(?<!\\\\)|(?<=^|[^\\\\])(\\\\{2})+)'","(?:(?<!\\\\)|(?<=^|[^\\\\])(\\\\{2})+)\"");
     1063        $encap_start = array(
     1064            's_quote' => "'",
     1065            'd_quote' => '"'
     1066        );
     1067        $encap_end = array(
     1068            's_quote' => "(?:(?<!\\\\)|(?<=^|[^\\\\])(\\\\{2})+)'",
     1069            'd_quote' => "(?:(?<!\\\\)|(?<=^|[^\\\\])(\\\\{2})+)\""
     1070        );
     1071       
    10641072        if($type === 'css') {
    1065             $encap_start[] = '(?:url|image)\\(';
    1066             $encap_end[] = '\\)';
     1073            $encap_start['url_func'] = '(?:url|image)\\(';
     1074            $encap_end['url_func'] = '\\)';
    10671075        } else {
    1068             $encap_start[] = '(?<=^|[[{};:=?(,*]|&&|\\|\\|)\s*/(?![/\\*])';
    1069             $encap_end[] = '(?:(?<!\\\\)|(?<=^|[^\\\\])(\\\\{2})+)/[gim]?';
     1076            $encap_start['regex'] = '(?<=^|[[{};:=?(,*!]|&&|\\|\\||return)\s*/(?![/\\*])';
     1077            $encap_end['regex'] = '(?:(?<!\\\\)|(?<=^|[^\\\\])(\\\\{2})+)/[gim]?';
    10701078        }
    10711079       
    10721080        // Comments that we want to capture.
    1073         $comments_start = array('//','/\\*');
    1074         $comments_end = array('(?:\\R|$)','\\*/');
     1081        $comments_start = array(
     1082            's_comment' => '//',
     1083            'm_comment' => '/\\*'
     1084        );
     1085        $comments_end = array(
     1086            's_comment' => '(?:\\R|$)',
     1087            'm_comment' => '\\*/'
     1088        );
    10751089       
    10761090        // Concatenate both arrays.
     
    10871101                       
    10881102            // Find the item that has triggered encapsulation.
    1089             $idx = -1;
     1103            $idx = false;
    10901104            foreach($total_start as $k => $e) {
    10911105                if(preg_match('@'.$e.'@i',$match[0][0])) {
     
    10991113            if(preg_match('@' . $total_end[$idx] . '@i',$source,$match_end,PREG_OFFSET_CAPTURE,$offset + strlen($match[0][0]))) {
    11001114                $en_len = strlen($match_end[0][0]);
    1101                
    1102                 //var_dump(substr($source,$offset,$match_end[0][1] - $offset + $en_len));
     1115                $captured_str = substr($source,$offset,$match_end[0][1] - $offset + $en_len);
     1116               
     1117                // If this is a regex, grab any open square brackets inside the captured string, as we want to exclude using contents within to end the regex.
     1118                if($idx === 'regex') {
     1119                    while(preg_match_all('@(?:(?<!\\\\)|(?<=^|[^\\\\])(?:\\\\{2})+)\\[([\\s\\S]*?(?:(?<!\\\\)|(?<=[^\\\\])(?:\\\\{2})+)\\])?@',$captured_str,$regex_match,PREG_OFFSET_CAPTURE)) {
     1120                        if(empty($regex_match[1][count($regex_match[1])-1])) {
     1121                            if(preg_match('@' . $total_end[$idx] . '@i',$source,$match_end,PREG_OFFSET_CAPTURE,$offset + strlen($captured_str))) {
     1122                                $captured_str = substr($source,$offset,$match_end[0][1] - $offset + $en_len);
     1123                            } else {
     1124                                // ERROR MESSAGE, end encapsulation tag not found.
     1125                                $ftype = $type === 'css' ? 'CSS' : 'Javascript';
     1126                                trigger_error(sprintf('There is an error in your %s file. An encapsulator like a string or regex was opened and was not closed: %s.',$ftype,$captured_str),E_USER_ERROR);
     1127                            }
     1128                        } else break;
     1129                    }
     1130                }
     1131               
     1132                //var_dump($captured_str);
    11031133                // If this is a comment, mark it for removal.
    11041134                if(array_search($total_start[$idx],$comments_start) !== false) {
    1105                     array_push($comments_store,substr($source,$offset,$match_end[0][1] - $offset + $en_len));
     1135                    array_push($comments_store,$captured_str);
    11061136                }
    11071137               
     
    11101140                // ERROR MESSAGE, end encapsulation tag not found.
    11111141                $ftype = $type === 'css' ? 'CSS' : 'Javascript';
    1112                 trigger_error(sprintf('There is an error in your %s file. An encapsulator like a string or regex was opened and was not closed: %s.',$ftype,substr($source,$offset)),E_USER_ERROR);
     1142                trigger_error(sprintf('There is an error in your %s file. An encapsulator like a string or regex was opened and was not closed: %s.',$ftype,$captured_str),E_USER_ERROR);
    11131143            }
    11141144           
  • html-minifier/trunk/readme.md

    r1995957 r2001833  
    55Requires at least: 3.6.4
    66Tested up to: 4.9.9
    7 Stable tag: 2.3.2
     7Stable tag: 2.3.3
    88Requires PHP: 5.4
    99License: GPLv2 or later
     
    2525== Changelog ==
    2626
     27= 2.3.3 =
     28*Release Date - 27 December 2018*
     29
     30* Fixed a bug with Javascript comment removal where certain instances of minified regexes would cause the functionality to go haywire and terminate the file immaturely.
     31* The plugin should be WordPress 5.0 compatible now, but more testing will be needed before it is officially labelled as such.
     32
    2733= 2.3.2 =
    2834*Release Date - 17 December 2018*
    2935
    30 * Fixed a major string detectioin bug with the regex behind handling Javascript and CSS comments. This bug caused HTML Minifier to completely fail in minifying some Javascript and CSS files.
     36* Fixed a major string detection bug with the regex behind handling Javascript and CSS comments. This bug caused HTML Minifier to completely fail in minifying some Javascript and CSS files.
    3137* Found some issues with the plugin's compatibility with WordPress 5.0 and above, so the Tested Up To tag for this plugin was rolled back to 4.9.9. Apologies to the users who had to find this out the hard way! A proper compatibility patch for WordPress 5.0 will be released soon.
    3238
Note: See TracChangeset for help on using the changeset viewer.