public void process(InputStream in, ZipEntry zipEntry) throws IOException { String root = getRootName(zipEntry.getName()); if (rootDir == null) { rootDir = root; } else if (!rootDir.equals(root)) { throw new ZipException("Unwrapping with multiple roots is not supported, roots: " + rootDir + ", " + root); } String name = mapper.map(getUnrootedName(root, zipEntry.getName())); if (name != null) { File file = makeDestinationFile(outputDir, name); if (zipEntry.isDirectory()) { FileUtils.forceMkdir(file); } else { FileUtils.forceMkdir(file.getParentFile()); if (log.isDebugEnabled() && file.exists()) { log.debug("Overwriting file '{}'.", zipEntry.getName()); } FileUtils.copy(in, file); } } }
public void process(InputStream in, ZipEntry zipEntry) throws IOException { String name = mapper.map(zipEntry.getName()); if (name != null) {
public void process(InputStream in, ZipEntry zipEntry) throws IOException { String name = mapper.map(zipEntry.getName()); if (name != null) { File file = makeDestinationFile(outputDir, name); if (zipEntry.isDirectory()) { FileUtils.forceMkdir(file); } else { FileUtils.forceMkdir(file.getParentFile()); if (log.isDebugEnabled() && file.exists()) { log.debug("Overwriting file '{}'.", zipEntry.getName()); } FileUtils.copy(in, file); } ZTFilePermissions permissions = ZipEntryUtil.getZTFilePermissions(zipEntry); if (permissions != null) { ZTFilePermissionsUtil.getDefaultStategy().setPermissions(file, permissions); } } } }
String name = mapper.map(path); if (name != null) { ZipEntry zipEntry = ZipEntryUtil.fromFile(name, file);
File fileToPack = filesToPack[i]; ZipEntry zipEntry = ZipEntryUtil.fromFile(mapper.map(fileToPack.getName()), fileToPack); out.putNextEntry(zipEntry); FileUtils.copy(fileToPack, out);
String mappedName = nameMapper.map(entry.getName()); if (mappedName == null) { continue; // we should ignore this entry
ZipEntry entry = entrySource.getEntry(); if (nameMapper != null) { String mappedName = nameMapper.map(entry.getName()); if (mappedName == null) { continue; // we should ignore this entry
@Override public String map(String name) { String result = delegate.map(name); if (result != null) { paths.add(parentPath.resolve(result)); } return result; } }
public void process(InputStream in, ZipEntry zipEntry) throws IOException { String root = getRootName(zipEntry.getName()); if (rootDir == null) { rootDir = root; } else if (!rootDir.equals(root)) { throw new ZipException("Unwrapping with multiple roots is not supported, roots: " + rootDir + ", " + root); } String name = mapper.map(getUnrootedName(root, zipEntry.getName())); if (name != null) { File file = new File(outputDir, name); /* If we see the relative traversal string of ".." we need to make sure * that the outputdir + name doesn't leave the outputdir. See * DirectoryTraversalMaliciousTest for details. */ if (name.indexOf("..") != -1 && !file.getCanonicalPath().startsWith(outputDir.getCanonicalPath())) { throw new ZipException("The file "+name+" is trying to leave the target output directory of "+outputDir+". Ignoring this file."); } if (zipEntry.isDirectory()) { FileUtils.forceMkdir(file); } else { FileUtils.forceMkdir(file.getParentFile()); if (log.isDebugEnabled() && file.exists()) { log.debug("Overwriting file '{}'.", zipEntry.getName()); } FileUtils.copy(in, file); } } }
public void process(InputStream in, ZipEntry zipEntry) throws IOException { String name = mapper.map(zipEntry.getName()); if (name != null) { File file = new File(outputDir, name); /* If we see the relative traversal string of ".." we need to make sure * that the outputdir + name doesn't leave the outputdir. See * DirectoryTraversalMaliciousTest for details. */ if (name.indexOf("..") != -1 && !file.getCanonicalPath().startsWith(outputDir.getCanonicalPath())) { throw new ZipException("The file "+name+" is trying to leave the target output directory of "+outputDir+". Ignoring this file."); } if (zipEntry.isDirectory()) { FileUtils.forceMkdir(file); } else { FileUtils.forceMkdir(file.getParentFile()); if (log.isDebugEnabled() && file.exists()) { log.debug("Overwriting file '{}'.", zipEntry.getName()); } FileUtils.copy(in, file); } ZTFilePermissions permissions = ZipEntryUtil.getZTFilePermissions(zipEntry); if (permissions != null) { ZTFilePermissionsUtil.getDefaultStategy().setPermissions(file, permissions); } } } }
public void process(InputStream in, ZipEntry zipEntry) throws IOException { String name = mapper.map(zipEntry.getName()); if (name != null) {
File fileToPack = filesToPack[i]; ZipEntry zipEntry = ZipEntryUtil.fromFile(mapper.map(fileToPack.getName()), fileToPack); out.putNextEntry(zipEntry); FileUtils.copy(fileToPack, out);
String name = mapper.map(path); if (name != null) { ZipEntry zipEntry = ZipEntryUtil.fromFile(name, file);
String mappedName = nameMapper.map(entry.getName()); if (mappedName == null) { continue; // we should ignore this entry
ZipEntry entry = entrySource.getEntry(); if (nameMapper != null) { String mappedName = nameMapper.map(entry.getName()); if (mappedName == null) { continue; // we should ignore this entry