Bug report #20549

QGIS SERVER - error in parsing WMS GetFeatureInfo as XML

Added by Umberto Minora over 5 years ago. Updated over 5 years ago.

Status:Closed
Priority:Normal
Assignee:Alessandro Pasotti
Category:QGIS Server
Affected QGIS version:3.4.1 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:28369

Description

Don't know if it's a real bug, but it's something I'd like to be fixed for my own application.
I use to parse the GetFeatureInfo request as XML with the ".responseXML" method.
I am receiving this error:
Errore interpretazione XML: tag corrispettivo mancante. Previsto: </meta>.
It seems the missing closing </meta> tag is causing this.
A testing URL for the request looks like this:
https://www.wondermap.it/cgi-bin/qgis_mapserv.fcgi?&map=/home/ubuntu/qgis/projects/Demo_sci_WMS/demo_sci.qgs&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=domini%20sciabili&LAYERS=domini%20sciabili&INFO_FORMAT=text%2Fhtml&I=50&J=50&CRS=EPSG%3A3857&STYLES=&WIDTH=101&HEIGHT=101&BBOX=1128900.381669475%2C5866529.499870181%2C1129865.3991515755%2C5867494.517352281

Associated revisions

Revision 0d696ef1
Added by Alessandro Pasotti over 5 years ago

[server] Fix invalid xml in getfeatureinfo

Fixes #20549 - error in parsing WMS GetFeatureInfo as XML

Also s/meta/META/ for consistency with all other tags

History

#1 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

No error here with the provided URL.

#2 Updated by Umberto Minora over 5 years ago

There's no error in the GetFeatureInfo request.
But if you look in the source (view-source:https://www.wondermap.it/cgi-bin/qgis_mapserv.fcgi?&map=/home/ubuntu/qgis/projects/Demo_sci_WMS/demo_sci.qgs&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=domini%20sciabili&LAYERS=domini%20sciabili&INFO_FORMAT=text%2Fhtml&I=50&J=50&CRS=EPSG%3A3857&STYLES=&WIDTH=101&HEIGHT=101&BBOX=1128900.381669475%2C5866529.499870181%2C1129865.3991515755%2C5867494.517352281) you'll notice that the <meta> tag is not closed.
This is fine from HTML point of view, but not in XML.
if you make (as I do) an XML HttpRequest and try to change the response to XML (see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML), it will fail.

#3 Updated by Umberto Minora over 5 years ago

The reason why I am using responseXML is to catch WMS Exception (see https://stackoverflow.com/a/51723660/1979665).

#4 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Feedback to Open

#5 Updated by Uroš Preložnik over 5 years ago

Umberto Minora wrote:

This is fine from HTML point of view, but not in XML.
if you make (as I do) an XML HttpRequest and try to change the response to XML (see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseXML), it will fail.

If you need response in XML, why not just ask it with INFO_FORMAT=text/xml instead of text/html.

#6 Updated by Umberto Minora over 5 years ago

Uroš Preložnik wrote:

If you need response in XML, why not just ask it with INFO_FORMAT=text/xml instead of text/html.

Because not all WMS accepts INFO_FORMAT=text/xml.
For example, Mapserver has default text/plain (https://mapserver.org/uk/ogc/wms_server.html#web-object-metadata).
I know it's not a big deal, but it's just to be cleaner in the response and allowing clients to be able to convert the server response to XML without getting this error. Again, I don't think it can be defined as bug though, it might be more a feature request.

#7 Updated by Alessandro Pasotti over 5 years ago

  • Status changed from Open to In Progress
  • Assignee set to Alessandro Pasotti

#8 Updated by Anonymous over 5 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

#9 Updated by Umberto Minora over 5 years ago

Thank you Alessandro, will test it soon!

#10 Updated by Umberto Minora over 5 years ago

Anyway, if I have installed qgis-server using the deb package, should I wait for the next release before I can test it?

#11 Updated by Alessandro Pasotti over 5 years ago

Yes, unless you test the nightly builds or a docker image built from a recent master

#12 Updated by Umberto Minora over 5 years ago

  • Status changed from Closed to Reopened

Don't know if I miss anything but I updated qgis-server to 3.4.2 expecting to see the closing meta tag resolved, but I seem to still have the same error.
From here I see this fix was included in the last release:https://github.com/qgis/QGIS/compare/final-3_4_2...master. However, looking at the GetFeatureInfo response of my WMS it seems the same as before: (view-source:https://www.wondermap.it/cgi-bin/qgis_mapserv.fcgi?map=/home/ubuntu/qgis/projects/Demo_sci_WMS/demo_sci.qgs&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=domini_sciabili&LAYERS=domini_sciabili&INFO_FORMAT=text%2Fhtml&I=50&J=50&CRS=EPSG%3A3857&STYLES=&WIDTH=101&HEIGHT=101&BBOX=1162989.3853589566%2C5840094.709100607%2C1170709.5252157594%2C5847814.848957409).
I tried to clear the cache, update QGIS DESKTOP and replacing the former qgs project on the server with the one saved with the newer (3.4.2) version, but still the same result.
Am I missing something? Thanks in advance for any feedback.

#13 Updated by Alessandro Pasotti over 5 years ago

I wasn't backported to 3.4, it will be in 3.6

#14 Updated by Giovanni Manghi over 5 years ago

  • Resolution set to fixed/implemented
  • Status changed from Reopened to Closed

Also available in: Atom PDF