Skip to content

Commit

Permalink
Import: "../" should not happen in any place
Browse files Browse the repository at this point in the history
  • Loading branch information
biochem-fan committed Oct 27, 2020
1 parent c7546fe commit 4ed89f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/apps/import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ class import_parameters
// For micrographs or movies
if (do_movies || do_micrographs)
{
if (fn_in.rfind("../", 0) == 0)
if (fn_in.rfind("../") != std::string::npos) // Forbid at any place
REPORT_ERROR("Please don't import files outside the project directory.\nPlease make a symbolic link by an absolute path before importing.");

if (fn_in.rfind("/", 0) == 0)
if (fn_in.rfind("/", 0) == 0) // Forbid only at the beginning
REPORT_ERROR("Please import files by a relative path.\nIf you want to import files outside the project directory, make a symbolic link by an absolute path and\nimport the symbolic link by a relative path.");

std::string tablename = (do_movies) ? "movies" : "micrographs";
Expand Down
4 changes: 2 additions & 2 deletions src/pipeline_jobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,13 +1127,13 @@ bool RelionJob::getCommandsImportJob(std::string &outputname, std::vector<std::s
{
fn_in = joboptions["fn_in_raw"].getString();

if (fn_in.rfind("../", 0) == 0)
if (fn_in.rfind("../") != std::string::npos) // Forbid at any place
{
error_message = "ERROR: don't import files outside the project directory.\nPlease make a symbolic link by an absolute path before importing.";
return false;
}

if (fn_in.rfind("/", 0) == 0)
if (fn_in.rfind("/", 0) == 0) // Forbid only at the beginning
{
error_message = "ERROR: please import files by a relative path.\nIf you want to import files outside the project directory, make a symbolic link by an absolute path and\nimport the symbolic link by a relative path.";
return false;
Expand Down

0 comments on commit 4ed89f7

Please sign in to comment.