Context
QGIS desktop should be able to work with QGIS Server, if the project is stored in Postgresql.
When QGIS Server is used with several different projects, the MAP parameter must be present to tell which project to use.
The following GetCapabilities requests are used against two different projects: one stored on the server filesystem and another stored in Postgresql:
- http://qgis.demo/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities&MAP=/home/qgis/projects/cartageologica.qgz
- http://qgis.demo/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities&MAP=postgresql%3A%3Fservice%3Dpg_geotuga%26sslmode%3Ddisable%26dbname%3D%26schema%3Dortos%26project%3Dteste
The second URL, which includes the Postgresql project, must be properly quoted to be properly handled on the QGIS Server side:
python -c "import urllib, sys; print urllib.quote(sys.argv[1])" "postgresql:?service=pg_geotuga&sslmode=disable&dbname=&schema=ortos&project=teste"
Describe the bug
There is no problem to add a QGIS Server url to QGIS desktop, using a MAP=<project on filesystem>.

There is no way to add QGIS Server urls with MAP=<Postgresql project>.

I've tried with both the quoted and unquoted URL:
- http://qgis.demo/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities&MAP=postgresql%3A%3Fservice%3Dpg_geotuga%26sslmode%3Ddisable%26dbname%3D%26schema%3Dortos%26project%3Dteste
- http://qgis.demo/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities&MAP=postgresql:?service=pg_geotuga&sslmode=disable&dbname=&schema=ortos&project=teste
The error is the same. The string passed to QGIS server is the same.
How to Reproduce
- Go to Add WMS/WMTS layer
- Add a QGIS Server with a URl that includes the Postgresql project
- Click connect to get the capabilities document
- The GetCapabilities fails.
QGIS and OS versions
- QGIS 3.8, 3.9-Master
- Ubuntu 19.04
- GDAL 3.0.1
Additional context
The server is able to answer only if the MAP string is quoted.
The entry point in the source code is the QgsWmsSettings::parseUri function.
This calls uri.setEncodedUri( uriString ); which does not properly quote the project part and send the request to the server like:
QUERY_STRING: VERSION=1.3.0&MAP=postgresql:?service=pg_geotuga&sslmode=disable&dbname=&schema=ortos&project=teste&SERVICE=WMS&REQUEST=GetCapabilities
The server breaks the parameters using the & character and the MAP becomes only:
21:04 INFO Server[7789]: MAP:postgresql:?service=pg_geotuga.
There are several possibilities...
- Change the postgresql project string format, removing the
& (this might break existing projects, but using & will be always a problem). Better now than later.
- Make this
uri.setEncodedUri( uriString ); function aware of the MAP parameter and create a proper quoted MAP string.
- Improve QGIS Server to recreate the proper MAP parameter. QGIS Server receives all the parameters, but separated by
&.
Context
QGIS desktop should be able to work with QGIS Server, if the project is stored in Postgresql.
When QGIS Server is used with several different projects, the MAP parameter must be present to tell which project to use.
The following GetCapabilities requests are used against two different projects: one stored on the server filesystem and another stored in Postgresql:
The second URL, which includes the Postgresql project, must be properly quoted to be properly handled on the QGIS Server side:
Describe the bug
There is no problem to add a QGIS Server url to QGIS desktop, using a
MAP=<project on filesystem>.There is no way to add QGIS Server urls with
MAP=<Postgresql project>.I've tried with both the quoted and unquoted URL:
The error is the same. The string passed to QGIS server is the same.
How to Reproduce
QGIS and OS versions
Additional context
The server is able to answer only if the MAP string is quoted.
The entry point in the source code is the
QgsWmsSettings::parseUrifunction.This calls
uri.setEncodedUri( uriString );which does not properly quote the project part and send the request to the server like:QUERY_STRING: VERSION=1.3.0&MAP=postgresql:?service=pg_geotuga&sslmode=disable&dbname=&schema=ortos&project=teste&SERVICE=WMS&REQUEST=GetCapabilitiesThe server breaks the parameters using the
&character and the MAP becomes only:21:04 INFO Server[7789]: MAP:postgresql:?service=pg_geotuga.There are several possibilities...
&(this might break existing projects, but using&will be always a problem). Better now than later.uri.setEncodedUri( uriString );function aware of the MAP parameter and create a proper quoted MAP string.&.