diff --git a/bbb-common-web/build.sbt b/bbb-common-web/build.sbt index b0d487da22..d750095767 100755 --- a/bbb-common-web/build.sbt +++ b/bbb-common-web/build.sbt @@ -109,5 +109,7 @@ libraryDependencies ++= Seq( "org.postgresql" % "postgresql" % "42.4.3", "org.hibernate" % "hibernate-core" % "5.6.1.Final", "org.flywaydb" % "flyway-core" % "7.8.2", - "com.zaxxer" % "HikariCP" % "4.0.3" + "com.zaxxer" % "HikariCP" % "4.0.3", + "org.apache.tika" % "tika-core" % "2.8.0", + "org.apache.tika" % "tika-parsers-standard-package" % "2.8.0" ) diff --git a/bbb-common-web/project/Dependencies.scala b/bbb-common-web/project/Dependencies.scala index c3db90290c..eea63c6324 100644 --- a/bbb-common-web/project/Dependencies.scala +++ b/bbb-common-web/project/Dependencies.scala @@ -23,6 +23,7 @@ object Dependencies { // Office and document conversion val apachePoi = "5.1.0" val nuProcess = "2.0.6" + val tika = "2.8.0" // Server val servlet = "4.0.1" @@ -56,6 +57,7 @@ object Dependencies { val poiXml = "org.apache.poi" % "poi-ooxml" % Versions.apachePoi val nuProcess = "com.zaxxer" % "nuprocess" % Versions.nuProcess + val tika = "org.apache.tika" % "tika-core" % Versions.tika val servletApi = "javax.servlet" % "javax.servlet-api" % Versions.servlet @@ -93,6 +95,7 @@ object Dependencies { Compile.apacheHttpAsync, Compile.poiXml, Compile.nuProcess, + Compile.tika, Compile.servletApi, Compile.apacheLang, Compile.apacheIo, diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/MimeTypeUtils.java b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/MimeTypeUtils.java index aa8a2d5277..dd913d8616 100644 --- a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/MimeTypeUtils.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/MimeTypeUtils.java @@ -11,6 +11,7 @@ public class MimeTypeUtils { private static final String DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; private static final String PPT = "application/vnd.ms-powerpoint"; private static final String PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; + private static final String TIKA_MSOFFICE = "application/x-tika-msoffice"; private static final String ODT = "application/vnd.oasis.opendocument.text"; private static final String RTF = "application/rtf"; private static final String TXT = "text/plain"; @@ -21,46 +22,45 @@ public class MimeTypeUtils { private static final String PNG = "image/png"; private static final String SVG = "image/svg+xml"; - private static final HashMap EXTENSIONS_MIME = new HashMap(16) { + private static final HashMap> EXTENSIONS_MIME = new HashMap>(16) { { - // Add all the supported files - put(FileTypeConstants.XLS, XLS); - put(FileTypeConstants.XLSX, XLSX); - put(FileTypeConstants.DOC, DOC); - put(FileTypeConstants.DOCX, DOCX); - put(FileTypeConstants.PPT, PPT); - put(FileTypeConstants.PPTX, PPTX); - put(FileTypeConstants.ODT, ODT); - put(FileTypeConstants.RTF, RTF); - put(FileTypeConstants.TXT, TXT); - put(FileTypeConstants.ODS, ODS); - put(FileTypeConstants.ODP, ODP); - put(FileTypeConstants.PDF, PDF); - put(FileTypeConstants.JPG, JPEG); - put(FileTypeConstants.JPEG, JPEG); - put(FileTypeConstants.PNG, PNG); - put(FileTypeConstants.SVG, SVG); + put(FileTypeConstants.DOC, Arrays.asList(DOC, DOCX, TIKA_MSOFFICE)); + put(FileTypeConstants.XLS, Arrays.asList(XLS, XLSX, TIKA_MSOFFICE)); + put(FileTypeConstants.PPT, Arrays.asList(PPT, PPTX, TIKA_MSOFFICE)); + put(FileTypeConstants.DOCX, Arrays.asList(DOCX)); + put(FileTypeConstants.PPTX, Arrays.asList(PPTX)); + put(FileTypeConstants.XLSX, Arrays.asList(XLSX)); + put(FileTypeConstants.ODT, Arrays.asList(ODT)); + put(FileTypeConstants.RTF, Arrays.asList(RTF)); + put(FileTypeConstants.TXT, Arrays.asList(TXT)); + put(FileTypeConstants.ODS, Arrays.asList(ODS)); + put(FileTypeConstants.ODP, Arrays.asList(ODP)); + put(FileTypeConstants.PDF, Arrays.asList(PDF)); + put(FileTypeConstants.JPG, Arrays.asList(JPEG)); + put(FileTypeConstants.JPEG, Arrays.asList(JPEG)); + put(FileTypeConstants.PNG, Arrays.asList(PNG)); + put(FileTypeConstants.SVG, Arrays.asList(SVG)); } }; - + public Boolean extensionMatchMimeType(String mimeType, String finalExtension) { - if(EXTENSIONS_MIME.containsKey(finalExtension.toLowerCase()) && - EXTENSIONS_MIME.get(finalExtension.toLowerCase()).equalsIgnoreCase(mimeType)) { - return true; - } else if(EXTENSIONS_MIME.containsKey(finalExtension.toLowerCase() + 'x') && - EXTENSIONS_MIME.get(finalExtension.toLowerCase() + 'x').equalsIgnoreCase(mimeType)) { - //Exception for MS Office files named with old extension but using internally the new mime type - //e.g. a file named with extension `ppt` but has the content of a `pptx` - return true; - } + finalExtension = finalExtension.toLowerCase(); + if (EXTENSIONS_MIME.containsKey(finalExtension)) { + for (String validMimeType : EXTENSIONS_MIME.get(finalExtension)) { + if (validMimeType.equalsIgnoreCase(mimeType)) { + return true; + } + } + } + return false; } public List getValidMimeTypes() { List validMimeTypes = Arrays.asList(XLS, XLSX, DOC, DOCX, PPT, PPTX, ODT, RTF, TXT, ODS, ODP, - PDF, JPEG, PNG, SVG + PDF, JPEG, PNG, SVG, TIKA_MSOFFICE ); return validMimeTypes; } diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/SlidesGenerationProgressNotifier.java b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/SlidesGenerationProgressNotifier.java index 9f8a9bcdb8..ea64b56f5d 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/SlidesGenerationProgressNotifier.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/presentation/imp/SlidesGenerationProgressNotifier.java @@ -58,7 +58,7 @@ public class SlidesGenerationProgressNotifier { pres.getTemporaryPresentationId(), pres.getName(), pres.getAuthzToken(), - "IVALID_MIME_TYPE", + "INVALID_MIME_TYPE", fileMime, fileExtension ); diff --git a/bigbluebutton-html5/imports/api/presentations/server/handlers/presentationConversionUpdate.js b/bigbluebutton-html5/imports/api/presentations/server/handlers/presentationConversionUpdate.js index 377c5f0bd6..996e5c6aeb 100755 --- a/bigbluebutton-html5/imports/api/presentations/server/handlers/presentationConversionUpdate.js +++ b/bigbluebutton-html5/imports/api/presentations/server/handlers/presentationConversionUpdate.js @@ -12,8 +12,8 @@ const PAGE_COUNT_EXCEEDED_KEY = 'PAGE_COUNT_EXCEEDED'; const PDF_HAS_BIG_PAGE_KEY = 'PDF_HAS_BIG_PAGE'; const GENERATED_SLIDE_KEY = 'GENERATED_SLIDE'; const FILE_TOO_LARGE_KEY = 'FILE_TOO_LARGE'; -const CONVERSION_TIMEOUT_KEY = "CONVERSION_TIMEOUT"; -const IVALID_MIME_TYPE_KEY = "IVALID_MIME_TYPE"; +const CONVERSION_TIMEOUT_KEY = 'CONVERSION_TIMEOUT'; +const INVALID_MIME_TYPE_KEY = 'INVALID_MIME_TYPE'; const NO_CONTENT = '204'; // const GENERATING_THUMBNAIL_KEY = 'GENERATING_THUMBNAIL'; // const GENERATED_THUMBNAIL_KEY = 'GENERATED_THUMBNAIL'; @@ -52,7 +52,7 @@ export default async function handlePresentationConversionUpdate({ body }, meeti statusModifier['conversion.maxFileSize'] = body.maxFileSize; case UNSUPPORTED_DOCUMENT_KEY: case OFFICE_DOC_CONVERSION_FAILED_KEY: - case IVALID_MIME_TYPE_KEY: + case INVALID_MIME_TYPE_KEY: statusModifier['conversion.error'] = true; statusModifier['conversion.fileMime'] = body.fileMime; statusModifier['conversion.fileExtension'] = body.fileExtension; diff --git a/bigbluebutton-html5/imports/ui/components/presentation/presentation-toast/presentation-uploader-toast/component.jsx b/bigbluebutton-html5/imports/ui/components/presentation/presentation-toast/presentation-uploader-toast/component.jsx index f0be52384e..c87a2549f2 100644 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-toast/presentation-uploader-toast/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-toast/presentation-uploader-toast/component.jsx @@ -54,7 +54,7 @@ const intlMessages = defineMessages({ id: 'app.presentationUploder.upload.413', description: 'error that file exceed the size limit', }, - IVALID_MIME_TYPE: { + INVALID_MIME_TYPE: { id: 'app.presentationUploder.conversion.invalidMimeType', description: 'warns user that the file\'s mime type is not supported or it doesn\'t match the extension', }, @@ -151,7 +151,7 @@ function renderPresentationItemStatus(item, intl) { case 'PDF_HAS_BIG_PAGE': constraint['0'] = (item.conversion.bigPageSize / 1000 / 1000).toFixed(2); break; - case 'IVALID_MIME_TYPE': + case 'INVALID_MIME_TYPE': constraint['0'] = item.conversion.fileExtension; constraint['1'] = item.conversion.fileMime; break; diff --git a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js index 8ce5da2963..27cb2fb831 100644 --- a/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js +++ b/bigbluebutton-html5/imports/ui/components/presentation/presentation-uploader/service.js @@ -108,7 +108,7 @@ const observePresentationConversion = ( if (doc.temporaryPresentationId !== temporaryPresentationId && doc.id !== tokenId) return; if (doc.conversion.status === 'FILE_TOO_LARGE' || doc.conversion.status === 'UNSUPPORTED_DOCUMENT' - || doc.conversion.status === 'CONVERSION_TIMEOUT' || doc.conversion.status === 'IVALID_MIME_TYPE') { + || doc.conversion.status === 'CONVERSION_TIMEOUT' || doc.conversion.status === 'INVALID_MIME_TYPE') { Presentations.update( { id: tokenId }, { $set: { temporaryPresentationId, renderedInToast: false } }, ); diff --git a/bigbluebutton-web/build.gradle b/bigbluebutton-web/build.gradle index 7fdf065589..27bee504cb 100755 --- a/bigbluebutton-web/build.gradle +++ b/bigbluebutton-web/build.gradle @@ -54,8 +54,6 @@ repositories { dependencies { runtimeOnly "com.bertramlabs.plugins:asset-pipeline-grails:4.0.0" - runtimeOnly 'org.apache.tika:tika-core:2.8.0' - runtimeOnly 'org.apache.tika:tika-parsers-standard-package:2.8.0' implementation "org.springframework:spring-core:5.3.21" implementation "org.springframework:spring-context:5.3.27"