Skip to content

Commit

Permalink
Fix regex validation for global inline flags
Browse files Browse the repository at this point in the history
Fixes #16676
  • Loading branch information
mvdbeek committed Sep 13, 2023
1 parent cd50265 commit 63442d1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/galaxy/dependencies/pinned-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ pyyaml==6.0 ; python_version >= "3.7" and python_version < "3.12"
pyzmq==25.1.0 ; python_version >= "3.7" and python_version < "3.12"
rdflib==6.2.0 ; python_version >= "3.7" and python_version < "3.12"
refgenconf==0.12.2 ; python_version >= "3.7" and python_version < "3.12"
regex==2023.8.8 ; python_version >= "3.7" and python_version < "3.12"
repoze-lru==0.7 ; python_version >= "3.7" and python_version < "3.12"
requests-oauthlib==1.3.1 ; python_version >= "3.7" and python_version < "3.12"
requests-toolbelt==1.0.0 ; python_version >= "3.7" and python_version < "3.12"
Expand Down
5 changes: 3 additions & 2 deletions lib/galaxy/tools/parameters/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import abc
import logging
import os.path
import re

import regex

from galaxy import (
model,
Expand Down Expand Up @@ -143,7 +144,7 @@ def validate(self, value, trans=None):
if not isinstance(value, list):
value = [value]
for val in value:
match = re.match(self.expression, val or "")
match = regex.match(self.expression, val or "")
super().validate(match is not None, value_to_show=val)


Expand Down
1 change: 1 addition & 0 deletions packages/app/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ install_requires =
PyJWT
PyYAML
refgenconf>=0.12.0
regex
requests
SQLAlchemy>=1.4.25,<2
sqlitedict
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ python-magic = "*"
python-multipart = "*" # required to support form parsing in FastAPI/Starlette
PyYAML = "*"
refgenconf = ">=0.12.0"
regex = "*"
requests = "*"
rocrate = "*"
Routes = "*"
Expand Down
12 changes: 12 additions & 0 deletions test/unit/app/tools/test_parameter_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,15 @@ def test_ExpressionValidator_message(self):
ValueError, r"Validator 'value.lower\(\) == \"foo\"' could not be evaluated on '1'"
):
p.validate(1)

def test_RegexValidator_global_flag_inline(self):
# tests that global inline flags continue to work past python 3.10
p = self._parameter_for(
xml=r"""
<param name="blah" type="text" value="">
<validator type="regex">^(?ims)\s*select\s+.*\s+from\s+.*$</validator>
</param>"""
)
p.validate("select id from job where id = 1;")
with self.assertRaises(ValueError):
p.validate("not sql")

0 comments on commit 63442d1

Please sign in to comment.