From 8b50de88b75d7af4ec8243964793bb4f6e154e1a Mon Sep 17 00:00:00 2001 From: Damian Jansen Date: Mon, 13 Aug 2018 18:19:40 +1000 Subject: [PATCH] fix(ZNTA-2744): prevent raw download on non-file project (#1019) --- .../main/java/org/zanata/action/VersionHomeAction.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/services/src/main/java/org/zanata/action/VersionHomeAction.java b/server/services/src/main/java/org/zanata/action/VersionHomeAction.java index 712afbabe7..9c3e0cf92b 100644 --- a/server/services/src/main/java/org/zanata/action/VersionHomeAction.java +++ b/server/services/src/main/java/org/zanata/action/VersionHomeAction.java @@ -674,8 +674,7 @@ public boolean isZipFileDownloadAllowed() { } public boolean isPoProject() { - HProjectIteration projectIteration = - projectIterationDAO.getBySlug(projectSlug, versionSlug); + HProjectIteration projectIteration = getVersion(); ProjectType type = projectIteration.getProjectType(); if (type == null) { type = projectIteration.getProject().getDefaultProjectType(); @@ -701,9 +700,7 @@ && getVersion().getProjectType() != ProjectType.Podir) { } public boolean isKnownProjectType() { - ProjectType type = projectIterationDAO - .getBySlug(projectSlug, versionSlug).getProjectType(); - return type != null; + return getVersion().getProjectType() != null; } public boolean isFileUploadAllowed(HLocale hLocale) { @@ -769,6 +766,9 @@ public String translationExtensionOf(String docPath, String docName) { } public boolean hasOriginal(String docPath, String docName) { + if (!isKnownProjectType() || getVersion().getProjectType() != ProjectType.File) { + return false; + } GlobalDocumentId id = new GlobalDocumentId(projectSlug, versionSlug, docPath + docName); return filePersistService.hasPersistedDocument(id);