From 2a4b33134883b80870b4b23e59ccd3b6cb7266a3 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 11 Sep 2017 21:18:55 -0400 Subject: Moved contrib.gis.geometry.regex to contrib.gis.geometry. --- django/contrib/gis/gdal/geometries.py | 2 +- django/contrib/gis/gdal/raster/source.py | 2 +- django/contrib/gis/geometry.py | 13 +++++++++++++ django/contrib/gis/geometry/__init__.py | 0 django/contrib/gis/geometry/regex.py | 13 ------------- django/contrib/gis/geos/geometry.py | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 django/contrib/gis/geometry.py delete mode 100644 django/contrib/gis/geometry/__init__.py delete mode 100644 django/contrib/gis/geometry/regex.py diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index 7b304d9af0..35ce8d5157 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -49,7 +49,7 @@ from django.contrib.gis.gdal.geomtype import OGRGeomType from django.contrib.gis.gdal.libgdal import GDAL_VERSION from django.contrib.gis.gdal.prototypes import geom as capi, srs as srs_api from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference -from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex +from django.contrib.gis.geometry import hex_regex, json_regex, wkt_regex from django.utils.encoding import force_bytes diff --git a/django/contrib/gis/gdal/raster/source.py b/django/contrib/gis/gdal/raster/source.py index 358bb44b8f..bf84eeef1a 100644 --- a/django/contrib/gis/gdal/raster/source.py +++ b/django/contrib/gis/gdal/raster/source.py @@ -16,7 +16,7 @@ from django.contrib.gis.gdal.raster.const import ( VSI_FILESYSTEM_BASE_PATH, VSI_TAKE_BUFFER_OWNERSHIP, ) from django.contrib.gis.gdal.srs import SpatialReference, SRSException -from django.contrib.gis.geometry.regex import json_regex +from django.contrib.gis.geometry import json_regex from django.utils.encoding import force_bytes, force_text from django.utils.functional import cached_property diff --git a/django/contrib/gis/geometry.py b/django/contrib/gis/geometry.py new file mode 100644 index 0000000000..6727c7d942 --- /dev/null +++ b/django/contrib/gis/geometry.py @@ -0,0 +1,13 @@ +import re + +# Regular expression for recognizing HEXEWKB and WKT. A prophylactic measure +# to prevent potentially malicious input from reaching the underlying C +# library. Not a substitute for good Web security programming practices. +hex_regex = re.compile(r'^[0-9A-F]+$', re.I) +wkt_regex = re.compile(r'^(SRID=(?P\-?\d+);)?' + r'(?P' + r'(?PPOINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|' + r'MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)' + r'[ACEGIMLONPSRUTYZ\d,\.\-\+\(\) ]+)$', + re.I) +json_regex = re.compile(r'^(\s+)?\{.*}(\s+)?$', re.DOTALL) diff --git a/django/contrib/gis/geometry/__init__.py b/django/contrib/gis/geometry/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/django/contrib/gis/geometry/regex.py b/django/contrib/gis/geometry/regex.py deleted file mode 100644 index 6727c7d942..0000000000 --- a/django/contrib/gis/geometry/regex.py +++ /dev/null @@ -1,13 +0,0 @@ -import re - -# Regular expression for recognizing HEXEWKB and WKT. A prophylactic measure -# to prevent potentially malicious input from reaching the underlying C -# library. Not a substitute for good Web security programming practices. -hex_regex = re.compile(r'^[0-9A-F]+$', re.I) -wkt_regex = re.compile(r'^(SRID=(?P\-?\d+);)?' - r'(?P' - r'(?PPOINT|LINESTRING|LINEARRING|POLYGON|MULTIPOINT|' - r'MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)' - r'[ACEGIMLONPSRUTYZ\d,\.\-\+\(\) ]+)$', - re.I) -json_regex = re.compile(r'^(\s+)?\{.*}(\s+)?$', re.DOTALL) diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py index e486190cc2..bcda25fa2f 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -6,7 +6,7 @@ import re from ctypes import addressof, byref, c_double from django.contrib.gis import gdal -from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex +from django.contrib.gis.geometry import hex_regex, json_regex, wkt_regex from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.coordseq import GEOSCoordSeq -- cgit v1.3