mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
MNT-16381 Transformers must validate the content stream mimetype
- Fix NPE in TransformerConfigImplTest git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130143 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -329,37 +329,40 @@ public class TransformerConfigImpl extends AbstractLifecycleBean implements Tran
|
|||||||
Map<String, Set<String>> strictMimetypeExceptions = new HashMap<>();
|
Map<String, Set<String>> strictMimetypeExceptions = new HashMap<>();
|
||||||
|
|
||||||
String whitelist = getProperty(STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES);
|
String whitelist = getProperty(STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES);
|
||||||
String[] mimetypes = whitelist.split(";");
|
if (whitelist != null)
|
||||||
|
|
||||||
if (mimetypes.length % 2 != 0)
|
|
||||||
{
|
{
|
||||||
logger.error(STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES+" should have an even number of mimetypes as a ; separated list.");
|
String[] mimetypes = whitelist.split(";");
|
||||||
}
|
|
||||||
else
|
if (mimetypes.length % 2 != 0)
|
||||||
{
|
|
||||||
Set<String> detectedMimetypes = null;
|
|
||||||
for (String mimetype: mimetypes)
|
|
||||||
{
|
{
|
||||||
mimetype = mimetype.trim();
|
logger.error(STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES+" should have an even number of mimetypes as a ; separated list.");
|
||||||
if (mimetype.isEmpty())
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Set<String> detectedMimetypes = null;
|
||||||
|
for (String mimetype: mimetypes)
|
||||||
{
|
{
|
||||||
logger.error(STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES+" contains a blank mimetype.");
|
mimetype = mimetype.trim();
|
||||||
// Still okay to use it in the map though, but it will be ignored.
|
if (mimetype.isEmpty())
|
||||||
}
|
{
|
||||||
|
logger.error(STRICT_MIMETYPE_CHECK_WHITELIST_MIMETYPES+" contains a blank mimetype.");
|
||||||
|
// Still okay to use it in the map though, but it will be ignored.
|
||||||
|
}
|
||||||
|
|
||||||
if (detectedMimetypes == null)
|
|
||||||
{
|
|
||||||
detectedMimetypes = strictMimetypeExceptions.get(mimetype);
|
|
||||||
if (detectedMimetypes == null)
|
if (detectedMimetypes == null)
|
||||||
{
|
{
|
||||||
detectedMimetypes = new HashSet<>();
|
detectedMimetypes = strictMimetypeExceptions.get(mimetype);
|
||||||
strictMimetypeExceptions.put(mimetype, detectedMimetypes);
|
if (detectedMimetypes == null)
|
||||||
|
{
|
||||||
|
detectedMimetypes = new HashSet<>();
|
||||||
|
strictMimetypeExceptions.put(mimetype, detectedMimetypes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
detectedMimetypes.add(mimetype);
|
||||||
|
detectedMimetypes = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
detectedMimetypes.add(mimetype);
|
|
||||||
detectedMimetypes = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user