Skip to content

Commit

Permalink
Improve regexp used by pymssql to parse db version
Browse files Browse the repository at this point in the history
Made improvements to the server version regexp used by the pymssql
dialect to prevent a regexp overflow in case of an invalid version
string.

Fixes: #5557
Change-Id: Ia3e95a9f11f5a121d84474c97f6b122cf8d9c9cf
  • Loading branch information
CaselIT committed Jun 21, 2021
1 parent 2f100a7 commit a84881e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions doc/build/changelog/unreleased_14/5557.rst
@@ -0,0 +1,6 @@
.. change::
:tags: mssql, change
:tickets: 6503, 6253

Made improvements to the server version regexp used by the pymssql dialect
to prevent a regexp overflow in case of an invalid version string.
2 changes: 1 addition & 1 deletion lib/sqlalchemy/dialects/mssql/pymssql.py
Expand Up @@ -94,7 +94,7 @@ def dbapi(cls):

def _get_server_version_info(self, connection):
vers = connection.exec_driver_sql("select @@version").scalar()
m = re.match(r"Microsoft .*? - (\d+).(\d+).(\d+).(\d+)", vers)
m = re.match(r"Microsoft .*? - (\d+)\.(\d+)\.(\d+)\.(\d+)", vers)
if m:
return tuple(int(x) for x in m.group(1, 2, 3, 4))
else:
Expand Down

0 comments on commit a84881e

Please sign in to comment.