Debian Codegraph @

django/contrib/gis/geometry.py

raw
1 import re
2
3 from django.utils.regex_helper import _lazy_re_compile
4
5 # Regular expression for recognizing HEXEWKB and WKT. A prophylactic measure
6 # to prevent potentially malicious input from reaching the underlying C
7 # library. Not a substitute for good web security programming practices.
8 hex_regex = _lazy_re_compile(r"^[0-9A-F]+$", re.I)
9 wkt_regex = _lazy_re_compile(
10 r"^(SRID=(?P<srid>\-?[0-9]+);)?"
11 r"(?P<wkt>"
12 r"(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|"
13 r"MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION|CIRCULARSTRING|COMPOUNDCURVE|"
14 r"CURVEPOLYGON|MULTICURVE|MULTISURFACE|CURVE|SURFACE|POLYHEDRALSURFACE|TIN|"
15 r"TRIANGLE)"
16 r"[ACEGIMLONPSRUTYZ0-9,.+() -]+)$",
17 re.I,
18 )
19 json_regex = _lazy_re_compile(r"^(\s+)?\{.*}(\s+)?$", re.DOTALL)