sqlmapproject/sqlmap · error · SqlmapCompressionException

detected invalid data for declared content encoding '%s' ('%

Error message

detected invalid data for declared content encoding '%s' ('%s')

What it means

Error "detected invalid data for declared content encoding '%s' ('%s')" thrown in sqlmapproject/sqlmap.

Source

Thrown at lib/request/basic.py:351

                    raise Exception("size too large")
                if not decompressor.eof:
                    raise Exception("incomplete Zstandard stream")
            else:
                data = gzip.GzipFile("", "rb", 9, io.BytesIO(page))
                page = data.read(MAX_CONNECTION_TOTAL_SIZE + 1)
                if len(page) > MAX_CONNECTION_TOTAL_SIZE:
                    raise Exception("size too large")
        except Exception as ex:
            if b"<html" not in page:  # in some cases, invalid "Content-Encoding" appears for plain HTML (should be ignored)
                errMsg = "detected invalid data for declared content "
                errMsg += "encoding '%s' ('%s')" % (contentEncoding, getSafeExString(ex))
                singleTimeLogMessage(errMsg, logging.ERROR)

                warnMsg = "turning off page compression"
                singleTimeWarnMessage(warnMsg)

                kb.pageCompress = False
                raise SqlmapCompressionException

    if not conf.encoding:
        httpCharset, metaCharset = None, None

        # Reference: http://stackoverflow.com/questions/1020892/python-urllib2-read-to-unicode
        if contentType.find("charset=") != -1:
            httpCharset = checkCharEncoding(contentType.split("charset=")[-1])

        metaCharset = checkCharEncoding(extractRegexResult(META_CHARSET_REGEX, page))

        if (any((httpCharset, metaCharset)) and (not all((httpCharset, metaCharset)) or isinstance(page, six.binary_type) and all(_ in PRINTABLE_BYTES for _ in page))) or (httpCharset == metaCharset and all((httpCharset, metaCharset))):
            kb.pageEncoding = httpCharset or metaCharset  # Reference: http://bytes.com/topic/html-css/answers/154758-http-equiv-vs-true-header-has-precedence
            debugMsg = "declared web page charset '%s'" % kb.pageEncoding
            singleTimeLogMessage(debugMsg, logging.DEBUG, debugMsg)
        else:
            kb.pageEncoding = None
    else:
        kb.pageEncoding = conf.encoding

View on GitHub (pinned to 0a35b20e39)

When it happens

Trigger: Thrown at lib/request/basic.py:351 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sqlmapproject/sqlmap@0a35b20e39 (2026-08-26). Data as JSON: /api/errors/4d4d8a31077ca342. Report an issue: GitHub.