Opened 11 years ago

Last modified 11 years ago

#2383 closed defect

Create extension with backslash_quote off — at Initial Version

Reported by: sbranchaw Owned by: pramsey
Priority: blocker Milestone: PostGIS 2.0.4
Component: raster Version: 2.0.x
Keywords: history Cc:

Description

Problem: backslash_quote has to be on in order to create the PostGIS extension.

This is an inconvenience because I have a nightly backup job that restores a compressed dump file to a database where backslash_quote is turned off for security reasons.

To reproduce:

  1. createdb postgis_testdb
  2. psql postgis_testdb
  3. SET backslash_quote = off;
  4. CREATE EXTENSION postgis;

Receive the error: postgis_testdb=# CREATE EXTENSION postgis; ERROR: unsafe use of \' in a string literal LINE 29: RAISE WARNING E'Format \'%\' is not recogniz…

HINT: Use to write quotes in strings. \' is insecure in client-only encodings. QUERY:

DECLARE

params text[]; rastout raster;

BEGIN

IF rast IS NULL THEN

RAISE WARNING 'Cannot set georeferencing on a null raster in st_setgeoreference.'; RETURN rastout;

END IF;

SELECT regexp_matches(georef,

E'(-?\\d+(?:\\.\\d+)?)\\s(-?\\d+(?:\\.\\d+)?)\\s(-?\\d+(?:\\.\\d+)?)\\s'

E'(-?\\d+(?:\\.\\d+)?)\\s(-?\\d+(?:\\.\\d+)?)\\s(-?\\d+(?:\\.\\d+)?)') INTO params;

IF NOT FOUND THEN

RAISE EXCEPTION 'st_setgeoreference requires a string with 6 floating point values.';

END IF;

IF format = 'ESRI' THEN

— params array is now: — {scalex, skewy, skewx, scaley, upperleftx, upperlefty} rastout := st_setscale(rast, params[1]::float8, params[4]::float8); rastout := st_setskew(rastout, params[3]::float8, params[2]::float8); rastout := st_setupperleft(rastout,

params[5]::float8 - (params[1]::float8 * 0.5), params[6]::float8 - (params[4]::float8 * 0.5));

ELSE

IF format != 'GDAL' THEN

RAISE WARNING E'Format \'%\' is not recognized, defaulting to GDAL format.', format;

END IF; — params array is now: — {scalex, skewy, skewx, scaley, upperleftx, upperlefty}

rastout := st_setscale(rast, params[1]::float8, params[4]::float8); rastout := st_setskew( rastout, params[3]::float8, params[2]::float8); rastout := st_setupperleft(rastout, params[5]::float8, params[6]::float8);

END IF; RETURN rastout;

END;

Change History (0)

Note: See TracTickets for help on using tickets.