Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cwltool/draft2tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
39 changes: 39 additions & 0 deletions tests/test_relax_path_checks.py
Original file line number Diff line number Diff line change
@@ -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()