diff --git a/resource-server-core/src/main/java/org/jasig/resource/aggr/RelativePath.java b/resource-server-core/src/main/java/org/jasig/resource/aggr/RelativePath.java index 537f75e0..4cfefbf5 100644 --- a/resource-server-core/src/main/java/org/jasig/resource/aggr/RelativePath.java +++ b/resource-server-core/src/main/java/org/jasig/resource/aggr/RelativePath.java @@ -26,11 +26,11 @@ /** * Utility for determining the relative path between two files. - * - * @author Eric Dalquist - * @version $Revision$ + * This is used for web URLs, so Windows backslash should not be used. */ public class RelativePath { + + public static final String separator = "/"; /** * break a path down into individual elements and add to a list. * example : if a path is /a/b/c/d.txt, the breakdown will be [d.txt,c,b,a] @@ -75,14 +75,14 @@ private static String matchPathLists(List<String> basePath, List<String> filePat // for each remaining level in the home path, add a .. for (; basePathItr.hasPrevious(); basePathItr.previous()) { - relativePath.append("..").append(File.separator); + relativePath.append("..").append(separator); } // for each level in the file path, add the path while (filePathItr.hasPrevious()) { relativePath.append(filePathItr.previous()); if (filePathItr.hasPrevious()) { - relativePath.append(File.separator); + relativePath.append(separator); } } diff --git a/resource-server-core/src/main/java/org/jasig/resource/aggr/ResourcesAggregatorImpl.java b/resource-server-core/src/main/java/org/jasig/resource/aggr/ResourcesAggregatorImpl.java index 24e1cf2d..7c86e810 100644 --- a/resource-server-core/src/main/java/org/jasig/resource/aggr/ResourcesAggregatorImpl.java +++ b/resource-server-core/src/main/java/org/jasig/resource/aggr/ResourcesAggregatorImpl.java @@ -21,16 +21,7 @@ */ package org.jasig.resource.aggr; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.Writer; +import java.io.*; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; @@ -364,9 +355,11 @@ protected <T extends BasicInclude> T aggregateList(final MessageDigest digest, f } final Reader resourceIn = new InputStreamReader(bomIs, this.encoding); if (element.isCompressed()) { - IOUtils.copy(resourceIn, trimmingWriter); - } - else { + final String resourceStr = IOUtils.toString(resourceIn); + final String resourceEolFix = resourceStr.replaceAll("\\r", ""); + final InputStream isEolFix = IOUtils.toInputStream(resourceEolFix, this.encoding); + IOUtils.copy(isEolFix, trimmingWriter, this.encoding); + } else { callback.compress(resourceIn, trimmingWriter); } } @@ -376,7 +369,7 @@ protected <T extends BasicInclude> T aggregateList(final MessageDigest digest, f finally { IOUtils.closeQuietly(fis); } - trimmingWriter.write(SystemUtils.LINE_SEPARATOR); + trimmingWriter.write(IOUtils.LINE_SEPARATOR_UNIX); // Needs to be consistent regardless of OS } } finally { @@ -460,7 +453,7 @@ protected String generatePathList(final Collection<? extends BasicInclude> eleme * * 2 {@link Css} objects are aggregatable if and only if: * <ol> - * <li>Neither object returns true for {@link #isAbsolute()}</li> + * <li>Neither object returns true for isAbsolute()</li> * <li>The values of their "conditional" properties are equivalent</li> * <li>The values of their "media" properties are equivalent</li> * <li>The "paths" of their values are equivalent</li> @@ -498,7 +491,7 @@ protected boolean willAggregateWith(Css first, Css second) { * * 2 {@link Js} objects are aggregatable if and only if: * <ol> - * <li>Neither object returns true for {@link #isAbsolute()}</li> + * <li>Neither object returns true for isAbsolute()</li> * <li>The values of their "conditional" properties are equivalent</li> * </ol> * @@ -506,7 +499,8 @@ protected boolean willAggregateWith(Css first, Css second) { * to compare each object's value. In short, the final file name in the value's path * need not be equal, but the rest of the path in the value must be equal. * - * @param other + * @param first + * @param second * @return */ protected boolean willAggregateWith(Js first, Js second) {