geometry.py 662 B

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