Skip to main content

RegXon is a powerful validator, sanitizer and content parser that you're searching for decades.

Project description

RegXon

RegXon is a powerful validator, sanitizer and content parser that you're searching for decades.

Installation

pip install regxon

Usage

from regxon.common import Regxon
regxon = Regxon()

General Validation

General validation includes email, domain, url and ipv4.

Validate Email

from regxon.common import Regxon

regxon = Regxon()
regxon.is_email('xyz@.com')  # False
regxon.is_email('xyz@cpx.com')  # True

Validate Domain

from regxon.common import Regxon

regxon = Regxon()
regxon.is_domain('xyzcom')  # False
regxon.is_domain('xyz.com')  # True

Validate URL

from regxon.common import Regxon

regxon = Regxon()
regxon.is_url('xyz.com')  # False
regxon.is_url('https://xyz.com')  # True

Validate IP

from regxon.common import Regxon

regxon = Regxon()
regxon.is_ipv4('http://xxz.com')  # False
regxon.is_ipv4('http://127.0.0.1')  # True
regxon.is_ipv4('127.0.0.1', schema='')  # True
regxon.is_ipv4('http://127.0.0.1', schema='')  # False

Validate Phone Number

from regxon.common import Regxon

regxon = Regxon()
regxon.is_phone('+91 1234567890')  # True

HTML Sanitization and Validation

HTML Validation includes validation of

from regxon.html import RegxonHTML

regxon_html = RegxonHTML()
html_content = """
<img onload="alert(1)" onerror="hey" src="http://example.com" />
<script>alert(1)</script>
"""
html = regxon_html.get_sanitized_content(html_content)

Add custom excluded attributes for any tag you want

from regxon.html import RegxonHTML

regxon_html = RegxonHTML()
html_content = """
<img onload="alert(1)" onerror="hey" src="http://example.com" />
<script>alert(1)</script>
"""

# Add custom excluded attributes for any tag you want
regxon_html.excluded_attributes.update({
    'img': regxon_html.excluded_attributes['img'] + ['onerror'],
})

Returned HTML will be

<img/>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

regxon-0.0.2-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page