Skip to content

Commit

Permalink
Merge pull request #15 from jasperroel/master
Browse files Browse the repository at this point in the history
Bugfix for <Path /> traversal in Web Optimization module
  • Loading branch information
aZahner committed Jan 25, 2013
2 parents 2287748 + b14a689 commit bb07630
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.PageContext;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;

/**
Expand Down Expand Up @@ -483,9 +484,16 @@ protected Locale resolveLocale(CmsObject cms, CmsXmlContent xml) {
*/
protected List<CmsResource> resolveResource(CmsObject cms, String path, String ext) throws CmsException {

List<CmsResource> resorces = new ArrayList<CmsResource>();

// An empty path is most probably a bug/unintentionally included. Ignoring it.
if (StringUtils.isBlank(path)) {
LOG.warn(Messages.get().getBundle().key(Messages.LOG_WARN_RESOLVE_EMPTY_PATH_1, cms.getRequestContext().getUri()));
return resorces;
}

CmsResource res = cms.readResource(path);

List<CmsResource> resorces = new ArrayList<CmsResource>();
if (res.isFolder()) {
// if folder, get all files with the given extension in the folder
List<CmsResource> files = cms.readResources(path, CmsResourceFilter.DEFAULT_FILES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public final class Messages extends A_CmsMessageBundle {
/** Message constant for key in the resource bundle. */
public static final String LOG_WARN_NOTHING_TO_PROCESS_1 = "LOG_WARN_NOTHING_TO_PROCESS_1";

/** Message constant for key in the resource bundle. */
public static final String LOG_WARN_RESOLVE_EMPTY_PATH_1 = "LOG_WARN_RESOLVE_EMPTY_PATH_1";

/** Name of the used resource bundle. */
private static final String BUNDLE_NAME = "com.alkacon.opencms.weboptimization.messages";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
LOG_WARN_NOTHING_TO_PROCESS_1 = Nothing to process for entry {0}
ERR_NOT_SUPPORTED_RESOURCE_TYPE_2 = Not supported resource type {1} of given resource {0}
ERR_NOT_SUPPORTED_RESOURCE_TYPE_2 = Not supported resource type {1} of given resource {0}
LOG_WARN_RESOLVE_EMPTY_PATH_1 =Tried to include an empty path while optimizing {0}. Ignoring entry.

0 comments on commit bb07630

Please sign in to comment.