Fix/wms provider url decoding#62446
Conversation
🍎 MacOS Qt6 buildsDownload MacOS Qt6 builds of this PR for testing. 🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
04ed226 to
739c6ec
Compare
|
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
|
While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist. |
|
ping @troopa81, for review please! |
739c6ec to
1f2418d
Compare
|
rebase from master |
|
@benoitdm-oslandia does this change break stable api? I.e would existing code relying on the old behavior (such as constructing a wms layer from a hard coded source string) be impacted? |
|
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
Sorry, what do you mean by hard coded? Can you provide a more precise usecase? |
|
I am 99% sure Nyall means URI strings that users might have saved and that are required to keep working. E. g. if you have a custom basemap plugin that contains a list of services defined by URIs. Will those keep working fine or is there potential breakage? |
|
@nyalldawson @kannes I am 99% sure the plugins will keep working fine :) The fixes brought by this PR are mainly to improve the support of url decoding and to homogeneize the uri encoding. But maybe some usecases are not tested! |
|
@nyalldawson I add some usecases in the test you mentioned and, from what I understood, it does not generate an API break. |
|
I will try to explain the situation. The current state is, parts of the source configuration is stored in the form of URL parameters. When the value of an individual key is retrieved, it is always decoded using The change in die PR will make sure values that are added to the QUrlQuery object are fully URL encoded (https://doc.qt.io/qt-6/qurl.html#ComponentFormattingOption-enum) first. The retrieval function QUrlQuery::queryItems parameter was changed from the default Why is this important? Now if we consume the WMS provided by QGIS server using a QGIS client the only way to make this work with current versions of QGIS is to double URL encode the values passed to the map parameter. That way at the time QGIS assembles the URL for an HTTP request to the server the value becomes single URL encoded because that is the way QUrlQuery::queryItems works by default. (The server acts only as an example here, but could be any data source that expects a URL parameter value the QGIS client would send in a URL encoded form) What this PR will break This will break projects that are currently using the double URL encoded value workaround in a datasource. In those cases the source configuration must be updated. After updating the double URL encoded URL parameter values to single URL encoded ones, those will start working again. (this must be added to breaking changes) General thoughts Using a URL-parameter String is probably not the best way to store/handle the configuration of a data source and maybe in the future it should be considered to switch to something that better fits the requirements (like XML that is already used anyway for project files). This PR makes sure though that we can work with the current URL parameter config in a reliable way. |
| const QString url = uriComponents[QStringLiteral( "url" )].toString(); | ||
| QUrl decodedUri = QUrl::fromPercentEncoding( uriComponents[QStringLiteral( "url" )].toString().toLocal8Bit() ); | ||
| if ( decodedUri.scheme().isEmpty() && decodedUri.path().startsWith( "http" ) ) | ||
| // url can be encoded twice and needs another % decoding |
There was a problem hiding this comment.
I don't get why they could be encoded twice ? or even once ? Here we get the non-encoded url, the one store in the layer. We encode only in QgsDataSourceUri::encodedUri(), no?
There was a problem hiding this comment.
After discussion, we should display the url as it was entered by the user. If he enters an already encoded URL, we display it encoded.
There was a problem hiding this comment.
In fact, as it is saved encoded, it had to be decoded at least once!
But why would you want to enter an already percent encoded URL. I understand that we can have a MAP or postgres url subpart that could be encoded but IMHO encoding the whole URL makes no sense. In the case of postgres/MAP subpart, we should let it encoded because it would be invalid otherwise. |
8d6daab to
bd10a30
Compare
|
@troopa81 I have found a bug with the vectortile provider while adjusting the tests. It does not seem a nice fix to me :( |
bd10a30 to
de40da8
Compare
…roperly decoded when retrieved, preventing any potential loss of information.
URl-encoded in URL-parameter values characters will be URL-decoded on retrieval.
…ded in tests/src/providers/testqgswmsprovider.cpp
2dbebd1 to
25ef836
Compare
troopa81
left a comment
There was a problem hiding this comment.
After long discussion and thorough reviewing, I'm OK with the PR in this actual state.
Thank you @benoitdm-oslandia
… QgsDataSourceUri param setter and getter functions to URI serialization QgsDataSourceUri::encodedUri()
…sDataSourceUri strings in QgsDataSourceUri::setEncodedUri
add decoding step before adding the "url" value to QgsDataSourceUri in TestQgsIdentify::identifyVectorTile(), as QgsDataSourceUri now reliably returns the values that were provided. adjust tests to QgsDataSourceUri full value URL-encoding fix test tests/src/core/testqgshttpheaders.cpp fix test tests/src/core/testqgssensorthingsconnection.cpp fix test tests/src/core/testqgstiledsceneconnection.cpp fix test tests/src/core/testqgsvectortileconnection.cpp fix test tests/src/python/test_qgsvectortile.py fix test tests/src/server/wms/test_qgsserver_wms_parameters.cpp fix tests tests/src/core/testqgshttpheaders.cpp fix most tests in tests/src/core/testqgsvectortilelayer.cpp
… of VectorTile Sources in QgsDataSurceUri
25ef836 to
0d10f88
Compare
|
Hi @benoitdm-oslandia, Also, some of the reported paths in the metadata look weird now and I don't think it was an intended behavior. |




This closes #62310 and reopens #59144 plus some changes:
closes #31192
closes #59143
cc @cioddi