]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Improve regexp used by pymssql to parse db version
authorFederico Caselli <cfederico87@gmail.com>
Mon, 21 Jun 2021 19:01:57 +0000 (21:01 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Mon, 21 Jun 2021 22:31:01 +0000 (22:31 +0000)
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

doc/build/changelog/unreleased_14/5557.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mssql/pymssql.py

diff --git a/doc/build/changelog/unreleased_14/5557.rst b/doc/build/changelog/unreleased_14/5557.rst
new file mode 100644 (file)
index 0000000..1fcae4f
--- /dev/null
@@ -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.
index 4cc6c4696c165bc93041d1ca917279d2bbfdabff..a8361e990b5ee7ef4d85475d4f077fe864a6075d 100644 (file)
@@ -94,7 +94,7 @@ class MSDialect_pymssql(MSDialect):
 
     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: