diff --git a/cwltool/draft2tool.py b/cwltool/draft2tool.py index afff4f741..4e0915e2d 100644 --- a/cwltool/draft2tool.py +++ b/cwltool/draft2tool.py @@ -25,7 +25,9 @@ from .job import CommandLineJob from .stdfsaccess import StdFsAccess -ACCEPTLIST_RE = re.compile(r"^[a-zA-Z0-9._+-]+$") +ACCEPTLIST_EN_STRICT_RE = re.compile(r"^[a-zA-Z0-9._+-]+$") +ACCEPTLIST_EN_RELAXED_RE = re.compile(r"^[ a-zA-Z0-9._+-]+$") # with spaces +ACCEPTLIST_RE = ACCEPTLIST_EN_STRICT_RE from .flatten import flatten diff --git a/cwltool/main.py b/cwltool/main.py index bdea236a3..0822eb519 100755 --- a/cwltool/main.py +++ b/cwltool/main.py @@ -178,6 +178,9 @@ def arg_parser(): # type: () -> argparse.ArgumentParser help="Do not compute checksum of contents while collecting outputs", dest="compute_checksum") + parser.add_argument("--relax-path-checks", action="store_true", + default=False, help="Relax requirements on path names. Currently " + "allows spaces.", dest="relax_path_checks") parser.add_argument("workflow", type=Text, nargs="?", default=None) parser.add_argument("job_order", nargs=argparse.REMAINDER) @@ -616,6 +619,8 @@ def main(argsl=None, _logger.error("") _logger.error("CWL document required, try --help for details") return 1 + if args.relax_path_checks: + draft2tool.ACCEPTLIST_RE = draft2tool.ACCEPTLIST_EN_RELAXED_RE try: document_loader, workflowobj, uri = fetch_document(args.workflow, resolver=tool_resolver) diff --git a/tests/test_relax_path_checks.py b/tests/test_relax_path_checks.py new file mode 100644 index 000000000..403d8e97e --- /dev/null +++ b/tests/test_relax_path_checks.py @@ -0,0 +1,39 @@ +import unittest +from tempfile import NamedTemporaryFile +from cwltool.main import main + + +class ToolArgparse(unittest.TestCase): + + + script=''' +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 +class: CommandLineTool +inputs: + - id: input + type: File + inputBinding: + position: 0 +outputs: + - id: output + type: File + outputBinding: + glob: test.txt +stdout: test.txt +baseCommand: [cat] +''' + + def test_spaces_in_input_files(self): + with NamedTemporaryFile() as f: + f.write(self.script) + f.flush() + with NamedTemporaryFile(prefix="test with spaces") as spaces: + self.assertEquals( + main(["--debug", f.name, '--input', spaces.name]), 1) + self.assertEquals( + main(["--debug", "--relax-path-checks", f.name, '--input', + spaces.name]), 0) + +if __name__ == '__main__': + unittest.main()