Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize invalid XML element names (attribute names) #902

Open
jmacura opened this issue Aug 7, 2023 · 3 comments
Open

Sanitize invalid XML element names (attribute names) #902

jmacura opened this issue Aug 7, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@jmacura
Copy link

jmacura commented Aug 7, 2023

When a layer which is being published contains attributes formed as URLs (which is common in the RDF world), the published layer may produce an invalid XML response.

e.g. for this GetFeatureInfo request on WMS layer:
https://hub4everybody.com/geoserver/franta_wms/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image/png&TRANSPARENT=true&QUERY_LAYERS=spoi_italy&LAYERS=spoi_italy&INFO_FORMAT=application/vnd.ogc.gml&feature_count=1&I=6&J=144&WIDTH=256&HEIGHT=256&CRS=EPSG:3857&STYLES=&BBOX=1023950.4309082218,5695017.229415342,1024103.3049647921,5695170.103471912

the returned FeatureCollection is

<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:franta_wms="http://franta_wms" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs https://hub4everybody.com/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd http://franta_wms https://hub4everybody.com/geoserver/franta_wms/wfs?service=WFS&amp;version=1.0.0&amp;request=DescribeFeatureType&amp;typeName=franta_wms%3Aspoi_italy">
  <gml:boundedBy>
    <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
      <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">1024018.8676,5693426.8733 1024018.8676,5693426.8733</gml:coordinates>
    </gml:Box>
  </gml:boundedBy>
  <gml:featureMember>
    <franta_wms:spoi_italy fid="spoi_italy.16816">
      <gml:boundedBy>
        <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
          <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">1024018.8676,5693426.8733 1024018.8676,5693426.8733</gml:coordinates>
        </gml:Box>
      </gml:boundedBy>
      <franta_wms:id>http://www.sdi4apps.eu/poi/#OSM_2516079384</franta_wms:id>
      <franta_wms:http://www.w3.org/1999/02/22_rdf_syntax_ns_type>http://gis.zcu.cz/SPOI/Ontology#restaurant</franta_wms:http://www.w3.org/1999/02/22_rdf_syntax_ns_type>
      <franta_wms:wkb_geometry>
        <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#3857">
          <gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">1024018.8676,5693426.8733</gml:coordinates>
        </gml:Point>
      </franta_wms:wkb_geometry>
    </franta_wms:spoi_italy>
  </gml:featureMember>
</wfs:FeatureCollection>

where <franta_wms:http://www.w3.org/1999/02/22_rdf_syntax_ns_type>...</franta_wms:http://www.w3.org/1999/02/22_rdf_syntax_ns_type> is not a valid XML node name.

see hslayers/hslayers-ng#4036

A correct response shall actually include <rdf:type>http://gis.zcu.cz/SPOI/Ontology#restaurant</rdf:type> instead of <franta_wms:http://www.w3.org/1999/02/22_rdf_syntax_ns_type>http://gis.zcu.cz/SPOI/Ontology#restaurant</franta_wms:http://www.w3.org/1999/02/22_rdf_syntax_ns_type>. With xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" in the XML header (or in the wfs:FeatureCollection node).

@jirik
Copy link
Member

jirik commented Aug 7, 2023

@jmacura Thanks for reporting. Could you please add also sample input file (GeoJSON or SHP)?

@jirik
Copy link
Member

jirik commented Aug 7, 2023

@jmacura
Copy link
Author

jmacura commented Aug 7, 2023

Provided the problematic layer is this one: https://hub4everybody.com/micka/record/basic/m-967bcafb-d0e0-4f91-9c28-f984cba7fde8 , I guess the original source was this GeoJSON: all-pois-italy.zip

Also, I can now confirm that even WFS GetFeature request contains the invalid XML tags.

@jirik jirik added this to the Future release milestone Aug 8, 2023
@jirik jirik added the enhancement New feature or request label Aug 8, 2023
@jirik jirik modified the milestones: Future release, Release v1.22 Aug 14, 2023
@jirik jirik modified the milestones: Release v1.22, Future release Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants