Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.3 KB

README.md

File metadata and controls

57 lines (40 loc) · 1.3 KB

turboguard

Build Coverage Status

Python C extension to validate and sanitize the user input using blacklist and character map.

Install

pip install turboguard

Quickstart.

Create an instance of the Sanitizer class as the below.

The Sanitizer.__enter__ method returns a callable(str) -> str which let you to call it many times without worring about performance and memory leak.

from turboguard import Sanitizer, BlacklistedError


blacklist = [
    ('\u1d100', '\u1d1ff'),   # Blacklist Unicode range
    '\u0635',                 # Blacklist single character
    ...
]

replace = [
    ('\u0636', '\u0637'),     # Replace \u0636 by \u0637
    ...
]

with Sanitizer(blacklist, replace) as sanitize:    # Loading(Slow) part
    try:
      print(sanitize('foo bar baz'))                 # Fast call!
    except BlacklistedError:
      print('Validation failed!')

Contribution

make env
make build
make cover

Afterward, for development sycle:

make clean build cover