diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 19db54e9a..80b3e3fb3 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1244,6 +1244,9 @@ Result Detector::getFileNamePrefix(Positions pos) const { } void Detector::setFileNamePrefix(const std::string &fname, Positions pos) { + if (fname.find_first_of("/ ") != std::string::npos) { + throw RuntimeError("Cannot set file name prefix with '/' or ' '"); + } pimpl->Parallel(&Module::setFileName, pos, fname); } diff --git a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp index 627bbe4d1..34d433591 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp @@ -572,6 +572,9 @@ TEST_CASE("fname", "[.cmd]") { proxy.Call("fname", {"run"}, -1, PUT, oss); REQUIRE(oss.str() == "fname run\n"); } + REQUIRE_THROWS(proxy.Call("fname", {"fdf/dfd"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("fname", {"fdf dfd"}, -1, PUT)); + for (int i = 0; i != det.size(); ++i) { det.setFileNamePrefix(prev_val[i], {i}); }