Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/com/yahoo/platform/yui/compressor/CssCompressor.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected String preserveToken(String css, String preservedToken,
boolean foundTerminator = false;

int endIndex = m.end() - 1;
while(foundTerminator == false && endIndex+1 <= maxIndex) {
while (foundTerminator == false && endIndex+1 <= maxIndex) {
endIndex = css.indexOf(terminator, endIndex+1);

if (endIndex <= 0) {
Expand All @@ -83,8 +83,9 @@ protected String preserveToken(String css, String preservedToken,

if (foundTerminator) {
String token = css.substring(startIndex, endIndex);
if(removeWhiteSpace)
if (removeWhiteSpace) [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should almost certainly end in a { rather than a [

token = token.replaceAll("\\s+", "");
}
preservedTokens.add(token);

String preserver = preservedToken + "(___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.size() - 1) + "___)";
Expand Down Expand Up @@ -369,7 +370,7 @@ public void compress(Writer out, int linebreakpos)
css = css.replaceAll("(:|\\s)0+\\.(\\d+)", "$1.$2");

// Shorten colors from rgb(51,102,153) to #336699
// This makes it more likely that it'll get further compressed in the next step.
// This makes it possible that it'll get further compressed in the next step.
p = Pattern.compile("rgb\\s*\\(\\s*([0-9,\\s]+)\\s*\\)");
m = p.matcher(css);
sb = new StringBuffer();
Expand Down Expand Up @@ -418,7 +419,7 @@ public void compress(Writer out, int linebreakpos)
// Restore, as is. Compression will break filters
sb.append(m.group(1) + "#" + m.group(2) + m.group(3) + m.group(4) + m.group(5) + m.group(6) + m.group(7));
} else {
if( m.group(2).equalsIgnoreCase(m.group(3)) &&
if (m.group(2).equalsIgnoreCase(m.group(3)) &&
m.group(4).equalsIgnoreCase(m.group(5)) &&
m.group(6).equalsIgnoreCase(m.group(7))) {

Expand Down Expand Up @@ -493,12 +494,12 @@ public void compress(Writer out, int linebreakpos)
css = sb.toString();
}

// Replace multiple semi-colons in a row by a single one
// Replace multiple semicolons in a row by a single one
// See SF bug #1980989
css = css.replaceAll(";;+", ";");

// restore preserved comments and strings
for(i = 0, max = preservedTokens.size(); i < max; i++) {
for (i = 0, max = preservedTokens.size(); i < max; i++) {
css = css.replace("___YUICSSMIN_PRESERVED_TOKEN_" + i + "___", preservedTokens.get(i).toString());
}

Expand Down