Minor patch
Some checks are pending
/ build (macos-latest, 3.8) (push) Waiting to run
/ build (ubuntu-latest, pypy-2.7) (push) Waiting to run
/ build (windows-latest, 3.14) (push) Waiting to run

This commit is contained in:
Miroslav Štampar 2026-07-19 18:54:15 +02:00
parent 2e28b70975
commit 6234b62c6f
3 changed files with 17 additions and 2 deletions

View file

@ -2955,7 +2955,12 @@ def extractErrorMessage(page):
if match:
candidate = htmlUnescape(match.group("result")).replace("<br>", "\n").strip()
if candidate and (1.0 * len(re.findall(r"[^A-Za-z,. ]", candidate)) / len(candidate) > MIN_ERROR_PARSING_NON_WRITING_RATIO):
# Note: only the generic '(fatal|error|warning|exception): ...' regexes can capture
# arbitrary prose, so guard those with the non-writing-char ratio; the specific
# DBMS-signature regexes (e.g. MSSQL 'Unclosed quotation mark ...') are definitive and
# must not be discarded just because the message happens to read like plain text
generic = "(fatal|error|warning|exception)" in regex
if candidate and (not generic or 1.0 * len(re.findall(r"[^A-Za-z,. ]", candidate)) / len(candidate) > MIN_ERROR_PARSING_NON_WRITING_RATIO):
retVal = candidate
break

View file

@ -20,7 +20,7 @@ from lib.core.enums import OS
from thirdparty import six
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
VERSION = "1.10.7.141"
VERSION = "1.10.7.142"
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)

View file

@ -1623,6 +1623,16 @@ class TestCommonRegexAndPage(unittest.TestCase):
def test_extract_error_message_none_for_plain(self):
self.assertIsNone(extractErrorMessage("Warning: This is only a dummy foobar test"))
def test_extract_error_message_prose_like_dbms_signature(self):
# a specific DBMS signature must be extracted even when it reads like plain text (few
# non-writing chars) - the non-writing-char ratio guards only the generic keyword regexes
page = "Microsoft OLE DB Provider for SQL Server error '80040e14' Unclosed quotation mark after the character string ''."
self.assertEqual(extractErrorMessage(page), "Unclosed quotation mark after the character string ''.")
def test_extract_error_message_generic_prose_still_rejected(self):
# the generic '(fatal|error|warning): ...' path must still drop natural-language prose
self.assertIsNone(extractErrorMessage("Error: everything is working fine and nothing is wrong here"))
def test_extract_error_message_non_string(self):
self.assertIsNone(extractErrorMessage(None))