Merged 5.2.N (5.2.1) to HEAD (5.2)

128176 adavis: MNT-16381 Transformers must validate the content stream mimetype
      - Tika has problems identifying eps - it guesses ps, so allow this through.
      - Fix lost line in DifferrentMimeTypeTest


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@129273 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alexandru Epure
2016-08-09 13:22:25 +00:00
parent 618ac2c7fe
commit abc10a475e
2 changed files with 10 additions and 4 deletions

View File

@@ -36,7 +36,8 @@ import java.util.concurrent.TimeoutException;
import org.alfresco.api.AlfrescoPublicApi;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.content.AbstractStreamAwareProxy;
import org.alfresco.repo.content.AbstractStreamAwareProxy;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.StreamAwareContentReaderProxy;
import org.alfresco.repo.content.StreamAwareContentWriterProxy;
import org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter;
@@ -252,7 +253,7 @@ public abstract class AbstractContentTransformer2 extends AbstractContentTransfo
// MNT-16381: check the mimetype of the file supplied by the user
// matches the sourceMimetype of the reader. Intermediate files are
// not checked.
strictMimeTypeCheck(reader, options);
strictMimeTypeCheck(reader, options, sourceMimetype);
// Check the transformability
checkTransformable(reader, writer, options);
@@ -438,13 +439,17 @@ public abstract class AbstractContentTransformer2 extends AbstractContentTransfo
}
}
private void strictMimeTypeCheck(ContentReader reader, TransformationOptions options)
private void strictMimeTypeCheck(ContentReader reader, TransformationOptions options, String sourceMimetype)
throws UnsupportedTransformationException
{
if (strictMimeTypeCheck && depth.get() == 1)
{
String differentType = getMimetypeService().getMimetypeIfNotMatches(reader.getReader());
if (differentType != null)
if (differentType != null &&
// Known problematic mimetypes for Tika to identify
!(MimetypeMap.MIMETYPE_APPLICATION_EPS.equals(sourceMimetype) &&
MimetypeMap.MIMETYPE_APPLICATION_PS.equals(differentType))
)
{
String fileName = transformerDebug.getFileName(options, true, 0);
String readerSourceMimetype = reader.getMimetype();