Page MenuHomePhabricator

DICOMEventHandler Crashes when loading DICOM data with special character in the file path
Closed, ResolvedPublic

Description

The MITK DICOM Browser crashes if you try to load a dicom file, that has a file path containing special characters.

Reason is that DicomEventHandler::OnSignalAddSeriesToDataManager uses QString::toStdString() to convert into an std::string. That may corrupt special characters and lead to GDCM failing when testing if it can read the file.

Potential solutions (after some web research):

  • QString's toLocal8Bit().constData() (due to windows)
  • std::codecvt and std::wstring_convert
WARNING: Check OnSignalAddSeriesToDataManager() for several instances of the error. It should be at least for normal DICOM images and RT Dose.

Event Timeline

Pushed new branch T23338-fix-dicom-loading-special-character.

I have successfully tested mitk-data/RT and mitk-data/DICOMReader with special characters within path.

@kislinsk I am not sure if there is a more generic special-character method which is platform indepenedent. I've read something about Boost (boost::filesystem::path) so maybe there is an alternative? Seems to me that this issue could be useful at other importer-like places too.

For now i would go with:

#ifdef Q_OS_WIN
	return string.toLocal8Bit().constData();
#elif Q_OS_MAC
	return string.toUtf8().constData();
#endif

@kislinsk I am not sure if there is a more generic special-character method which is platform indepenedent. I've read something about Boost (boost::filesystem::path) so maybe there is an alternative? Seems to me that this issue could be useful at other importer-like places too.

FYI boost filesystem would introduce the need of boost binaries into the DICOM module. Would be great of we can keep it boost header only.

hentsch moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.May 2 2018, 11:14 AM