@ -28,10 +28,10 @@ import org.airsonic.player.service.StatusService;
import org.airsonic.player.upload.MonitoredDiskFileItemFactory ;
import org.airsonic.player.upload.MonitoredDiskFileItemFactory ;
import org.airsonic.player.upload.UploadListener ;
import org.airsonic.player.upload.UploadListener ;
import org.airsonic.player.util.FileUtil ;
import org.airsonic.player.util.FileUtil ;
import org.airsonic.player.util.StringUtil ;
import org.apache.commons.fileupload.FileItem ;
import org.apache.commons.fileupload.FileItem ;
import org.apache.commons.fileupload.FileItemFactory ;
import org.apache.commons.fileupload.FileItemFactory ;
import org.apache.commons.fileupload.servlet.ServletFileUpload ;
import org.apache.commons.fileupload.servlet.ServletFileUpload ;
import org.apache.commons.lang.StringEscapeUtils ;
import org.slf4j.Logger ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.slf4j.LoggerFactory ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
@ -127,7 +127,7 @@ public class UploadController {
File targetFile = new File ( dir , new File ( fileName ) . getName ( ) ) ;
File targetFile = new File ( dir , new File ( fileName ) . getName ( ) ) ;
if ( ! securityService . isUploadAllowed ( targetFile ) ) {
if ( ! securityService . isUploadAllowed ( targetFile ) ) {
throw new Exception ( "Permission denied: " + StringUtil . to Html ( targetFile . getPath ( ) ) ) ;
throw new Exception ( "Permission denied: " + StringEscapeUtils . escape Html ( targetFile . getPath ( ) ) ) ;
}
}
if ( ! dir . exists ( ) ) {
if ( ! dir . exists ( ) ) {
@ -174,13 +174,13 @@ public class UploadController {
ZipEntry entry = ( ZipEntry ) entries . nextElement ( ) ;
ZipEntry entry = ( ZipEntry ) entries . nextElement ( ) ;
File entryFile = new File ( file . getParentFile ( ) , entry . getName ( ) ) ;
File entryFile = new File ( file . getParentFile ( ) , entry . getName ( ) ) ;
if ( ! entryFile . toPath ( ) . normalize ( ) . startsWith ( file . getParentFile ( ) . toPath ( ) ) ) {
if ( ! entryFile . toPath ( ) . normalize ( ) . startsWith ( file . getParentFile ( ) . toPath ( ) ) ) {
throw new Exception ( "Bad zip filename: " + StringUtil . to Html ( entryFile . getPath ( ) ) ) ;
throw new Exception ( "Bad zip filename: " + StringEscapeUtils . escape Html ( entryFile . getPath ( ) ) ) ;
}
}
if ( ! entry . isDirectory ( ) ) {
if ( ! entry . isDirectory ( ) ) {
if ( ! securityService . isUploadAllowed ( entryFile ) ) {
if ( ! securityService . isUploadAllowed ( entryFile ) ) {
throw new Exception ( "Permission denied: " + StringUtil . to Html ( entryFile . getPath ( ) ) ) ;
throw new Exception ( "Permission denied: " + StringEscapeUtils . escape Html ( entryFile . getPath ( ) ) ) ;
}
}
entryFile . getParentFile ( ) . mkdirs ( ) ;
entryFile . getParentFile ( ) . mkdirs ( ) ;