diff --git a/apps/qubit/modules/object/actions/importSelectAction.class.php b/apps/qubit/modules/object/actions/importSelectAction.class.php index 78d32032d7..497ffdd3c4 100644 --- a/apps/qubit/modules/object/actions/importSelectAction.class.php +++ b/apps/qubit/modules/object/actions/importSelectAction.class.php @@ -179,7 +179,13 @@ protected function doBackgroundImport($request) $this->redirect($importSelectRoute); } - // Redirect user if they are attempting to upload an invalid CSV file + // Redirect user if they are attempting to upload an invalid CSV/XML file + if ('xml' == $importType && 'xml' !== strtolower(pathinfo($file['name'], PATHINFO_EXTENSION))) { + $errorMessage = $this->context->i18n->__('Not an XML file.'); + $this->context->user->setFlash('error', $errorMessage); + $this->redirect($importSelectRoute); + } + if ('csv' == $importType && !$this->checkForValidCsvFile($request, $file['tmp_name'])) { $errorMessage = $this->context->i18n->__('Not a CSV file (or CSV columns not recognized).'); $this->context->user->setFlash('error', $errorMessage); diff --git a/apps/qubit/modules/object/actions/validateCsvAction.class.php b/apps/qubit/modules/object/actions/validateCsvAction.class.php index 4c1cda6897..bd763c84f4 100644 --- a/apps/qubit/modules/object/actions/validateCsvAction.class.php +++ b/apps/qubit/modules/object/actions/validateCsvAction.class.php @@ -73,6 +73,12 @@ protected function doBackgroundValidate($request) $this->redirect($validateCsvRoute); } + if ('csv' !== strtolower(pathinfo($file['name'], PATHINFO_EXTENSION))) { + $errorMessage = $this->context->i18n->__('Not a CSV file.'); + $this->context->user->setFlash('error', $errorMessage); + $this->redirect($validateCsvRoute); + } + // if we got here without a file upload, go to file selection if (0 == count($file) || empty($file['tmp_name'])) { $this->redirect($validateCsvRoute); @@ -83,7 +89,7 @@ protected function doBackgroundValidate($request) // Choose import type based on importType parameter // This decision used to be based in the file extension but some users // experienced problems when the extension was omitted - 'importType' => $importType, + 'importType' => 'csv', 'file' => $file, ]; diff --git a/apps/qubit/modules/object/templates/importSelectSuccess.php b/apps/qubit/modules/object/templates/importSelectSuccess.php index 50461ce113..b826561ef7 100644 --- a/apps/qubit/modules/object/templates/importSelectSuccess.php +++ b/apps/qubit/modules/object/templates/importSelectSuccess.php @@ -158,8 +158,9 @@