1#!/usr/bin/env python
2
3"""
4Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
5See the file 'LICENSE' for copying permission
6"""
7
8import re
9
10from lib.core.enums import PRIORITY
11
12__priority__ = PRIORITY.LOW
13
14def dependencies():
15    pass
16
17def tamper(payload, **kwargs):
18    """
19    HTML encode (using code points) all non-alphanumeric characters (e.g. ' -> ')
20
21    >>> tamper("1' AND SLEEP(5)#")
22    '1' AND SLEEP(5)#'
23    """
24
25    return re.sub(r"[^\w]", lambda match: "&#%d;" % ord(match.group(0)), payload) if payload else payload
26