Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix MSIE conditionals regex in minify output #2120

Merged
merged 3 commits into from

2 participants

@mikezilla

Allows IE conditionals like the following to remain unmodified (from html5boilerplate):

<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->

Without the change, the comment is not fully removed, remains unclosed, and the entire document is treated as commented!

Credit to joebert - regex from
http://www.sitepoint.com/forums/showthread.php?696559-Regex-pattern-to-strip-HTML-comments-but-leave-conditonals&s=3eef4ceb0a59b2fdb946fa56220fb6fd&p=4678083&viewfull=1#post4678083

Michael Dodge added some commits
Michael Dodge Fix MSIE conditionals regex in minify output func
Allows IE conditionals like the following to remain unmodified.

<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->

Credit to joebert regex from
http://www.sitepoint.com/forums/showthread.php?696559-Regex-pattern-to-strip-HTML-comments-but-leave-conditonals&s=3eef4ceb0a59b2fdb946fa56220fb6fd&p=4678083&viewfull=1#post4678083
8e12c78
Michael Dodge Revert "Fix MSIE conditionals regex in minify output func"
This reverts commit 8e12c787042396e172a7448c65bd16c3015ffb0f.
362b800
Michael Dodge Fix MSIE conditionals regex in minify output
Allows IE conditionals like the following to remain unmodified.
```html
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
```
Credit to joebert regex from

http://www.sitepoint.com/forums/showthread.php?696559-Regex-pattern-to-strip-HTML-comments-but-leave-conditonals&s=3eef4ceb0a59b2fdb946fa56220fb6fd&p=4678083&viewfull=1#post4678083
4d02e35
@mikezilla mikezilla referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@mikezilla mikezilla referenced this pull request in pyrocms/pyrocms
Merged

Fix MSIE conditionals regex in minify output #2199

@narfbg narfbg merged commit 85adeed into bcit-ci:develop

1 check failed

Details default The Travis build failed
@narfbg narfbg referenced this pull request from a commit
@narfbg narfbg Remove output minifier
This feature has proven to be problematic and it's not nearly
as flexible as a dedicated minifier library like Minify
(http://www.minifier.org/, https://github.com/matthiasmullie/minify).

The same results in terms of saving traffic can also be achievied via
gzip compression (which should also be done on the httpd level, but we
also support anyway) and stuff like mod_pagespeed.

Reverts PR #965

Related issues as a track record proving how problematic this has been:

#2078 #1499 #2163 #2092 #2387 #2637 #2710 #2120 #2171 #2631 #2326 #2795
#2791 #2772

Additionally, the count of contributors suggesting that the only way
to fix the minifier problems is to remove it, is around the same as
the count of people suggesting the feature to be implemented in the
first place. It was experimental anyway ... the experiment failed.
466e8cc
@ghost Unknown referenced this pull request from a commit in goreilly/CodeIgniter
@narfbg narfbg Remove output minifier
This feature has proven to be problematic and it's not nearly
as flexible as a dedicated minifier library like Minify
(http://www.minifier.org/, https://github.com/matthiasmullie/minify).

The same results in terms of saving traffic can also be achievied via
gzip compression (which should also be done on the httpd level, but we
also support anyway) and stuff like mod_pagespeed.

Reverts PR #965

Related issues as a track record proving how problematic this has been:

#2078 #1499 #2163 #2092 #2387 #2637 #2710 #2120 #2171 #2631 #2326 #2795
#2791 #2772

Additionally, the count of contributors suggesting that the only way
to fix the minifier problems is to remove it, is around the same as
the count of people suggesting the feature to be implemented in the
first place. It was experimental anyway ... the experiment failed.
03dadb9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 5, 2013
  1. Fix MSIE conditionals regex in minify output func

    Michael Dodge authored
    Allows IE conditionals like the following to remain unmodified.
    
    <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    
    Credit to joebert regex from
    http://www.sitepoint.com/forums/showthread.php?696559-Regex-pattern-to-strip-HTML-comments-but-leave-conditonals&s=3eef4ceb0a59b2fdb946fa56220fb6fd&p=4678083&viewfull=1#post4678083
  2. Revert "Fix MSIE conditionals regex in minify output func"

    Michael Dodge authored
    This reverts commit 8e12c787042396e172a7448c65bd16c3015ffb0f.
  3. Fix MSIE conditionals regex in minify output

    Michael Dodge authored
    Allows IE conditionals like the following to remain unmodified.
    ```html
    <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    ```
    Credit to joebert regex from
    
    http://www.sitepoint.com/forums/showthread.php?696559-Regex-pattern-to-strip-HTML-comments-but-leave-conditonals&s=3eef4ceb0a59b2fdb946fa56220fb6fd&p=4678083&viewfull=1#post4678083
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  system/core/Output.php
View
2  system/core/Output.php
@@ -739,7 +739,7 @@ public function minify($output, $type = 'text/html')
$output = preg_replace('!\s{2,}!', ' ', $output);
// Remove comments (non-MSIE conditionals)
- $output = preg_replace('{\s*<!--[^\[].*-->\s*}msU', '', $output);
+ $output = preg_replace('{\s*<!--[^\[<>].*(?<!!)-->\s*}msU', '', $output);
// Remove spaces around block-level elements.
$output = preg_replace('/\s*(<\/?(html|head|title|meta|script|link|style|body|h[1-6]|div|p|br)[^>]*>)\s*/is', '$1', $output);
Something went wrong with that request. Please try again.