2010-01-27 11:32:30 +08:00
|
|
|
import re
|
|
|
|
|
|
|
|
# Regular expression for recognizing HEXEWKB and WKT. A prophylactic measure
|
|
|
|
# to prevent potentially malicious input from reaching the underlying C
|
2010-10-09 16:12:50 +08:00
|
|
|
# library. Not a substitute for good Web security programming practices.
|
2010-01-27 11:32:30 +08:00
|
|
|
hex_regex = re.compile(r'^[0-9A-F]+$', re.I)
|
2011-09-17 05:19:30 +08:00
|
|
|
wkt_regex = re.compile(r'^(SRID=(?P<srid>\-?\d+);)?'
|
2010-01-27 11:32:30 +08:00
|
|
|
r'(?P<wkt>'
|
2014-09-04 20:15:09 +08:00
|
|
|
r'(?P<type>POINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|'
|
|
|
|
r'MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)'
|
2010-01-27 11:32:30 +08:00
|
|
|
r'[ACEGIMLONPSRUTYZ\d,\.\-\(\) ]+)$',
|
|
|
|
re.I)
|
2013-11-01 01:15:54 +08:00
|
|
|
json_regex = re.compile(r'^(\s+)?\{.*}(\s+)?$', re.DOTALL)
|