Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
stamparm committed Dec 23, 2022
1 parent 4cd146c commit dd4010f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
40 changes: 35 additions & 5 deletions lib/core/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import math
import os
import random
import re
import sys
import time
import uuid
Expand Down Expand Up @@ -277,8 +278,37 @@ def __hash__(self):
xrange = xrange
buffer = buffer

try:
from packaging import version
LooseVersion = version.parse
except ImportError:
from distutils.version import LooseVersion
def LooseVersion(version):
"""
>>> LooseVersion("1.0") == LooseVersion("1.0")
True
>>> LooseVersion("1.0.1") > LooseVersion("1.0")
True
>>> LooseVersion("1.0.1-") == LooseVersion("1.0.1")
True
>>> LooseVersion("1.0.11") < LooseVersion("1.0.111")
True
>>> LooseVersion("foobar") > LooseVersion("1.0")
False
>>> LooseVersion("1.0") > LooseVersion("foobar")
False
>>> LooseVersion("3.22-mysql") == LooseVersion("3.22-mysql-ubuntu0.3")
True
>>> LooseVersion("8.0.22-0ubuntu0.20.04.2")
8.000022
"""

match = re.search(r"\A(\d[\d.]*)", version or "")

if match:
result = 0
value = match.group(1)
weight = 1.0
for part in value.strip('.').split('.'):
if part.isdigit():
result += int(part) * weight
weight *= 1e-3
else:
result = float("NaN")

return result
2 changes: 1 addition & 1 deletion lib/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from thirdparty.six import unichr as _unichr

# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.6.12.8"
VERSION = "1.6.12.9"
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
Expand Down

0 comments on commit dd4010f

Please sign in to comment.