qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.03k stars 2.92k forks source link

Hyperlinks truncated when copied/followed from the identify results dialog #42446

Open Michael-cd30 opened 3 years ago

Michael-cd30 commented 3 years ago

Describe the bug

Hyperlinks might be truncated when copied and followed from the "identify results dialog".

How to Reproduce

  1. Create a geojson file with that content

{ "type": "FeatureCollection", "name": "link", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, "features": [ { "type": "Feature", "properties": { "link": "https:\/\/www.geoportail.gouv.fr\/carte?c=4.18014764696659,43.9934923817775&z=18&l0=TRANSPORTNETWORK.COMMONTRANSPORTELEMENTS.MARKERPOST_VISU::GEOPORTAIL:OGC:WMTS(1)&permalink=yes" }, "geometry": { "type": "Point", "coordinates": [ 4.18014764696659, 43.9934923817775 ] } } ] }

  1. Open it on QGis

  2. Select the point and on the identify results dialog copy or follow the link

The paste result is https://www.geoportail.gouv.fr/carte?c=4.18014764696659,43.9934923817775&z=18&l0=TRANSPORTNETWORK.COMMONTRANSPORTELEMENTS.MARKERPOST_VISU::GEOPORTAIL:OGC:WMTS(1)

but shoud be

https://www.geoportail.gouv.fr/carte?c=4.18014764696659,43.9934923817775&z=18&l0=TRANSPORTNETWORK.COMMONTRANSPORTELEMENTS.MARKERPOST_VISU::GEOPORTAIL:OGC:WMTS(1)&permalink=yes

QGIS and OS versions QGis 3.18.1 Windows 10

Additional context The copy/paste works from the attributes dialogs. The problem also occurs when the links is in a Postgis table. Tested with other links containing parenthesis, doesn't seem to be the reason; this one works : http://ang.wikipedia.org/wiki/Wikipedia:Tutorial_(Wikipedia_links).

roya0045 commented 3 years ago

Is it for hyperlinks only or does the & anywhere in text treated the same?

agiudiceandrea commented 3 years ago

@roya0045 it seems the issue is related to the parentheses (round brackets) in the link not to the ampersand:

https://user-images.githubusercontent.com/16253859/112371815-55cc9a80-8cdf-11eb-86b3-e3fa41a28e5b.mp4

agiudiceandrea commented 3 years ago

I think the problem lies in the RegEx string used to match a valid URL in QStringUtils::insertLinks https://github.com/qgis/QGIS/blob/929b7086b1bf294bc45b6342434c49d0b4d128ed/src/core/qgsstringutils.cpp#L521-L529 as QStringUtils::insertLinks is used to add links to the value displayed in the Identify Results dialog qgsidentifyresultsdialog.cpp

roya0045 commented 3 years ago

@agiudiceandrea as regex are being reworked a QRegularExpression could be proposed in that pr or as a standalone pr.

agiudiceandrea commented 1 year ago

This issue is still occurring in the latest QGIS version 3.26.2. See https://github.com/qgis/QGIS/issues/50066.