Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for <Path /> traversal in Web Optimization module #15

Merged
merged 1 commit into from
Jan 25, 2013
Merged
Show file tree
Hide file tree
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
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.