Skip to content

Commit 876a84d

Browse files
committed
MetaSearch: clean OWS URL when adding from search (http://hub.qgis.org/issues/16261)
1 parent 4f3719c commit 876a84d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

python/plugins/MetaSearch/dialogs/maindialog.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
from MetaSearch.dialogs.newconnectiondialog import NewConnectionDialog
5050
from MetaSearch.dialogs.recorddialog import RecordDialog
5151
from MetaSearch.dialogs.xmldialog import XMLDialog
52-
from MetaSearch.util import (get_connections_from_file, get_ui_class,
53-
get_help_url, highlight_xml, normalize_text,
54-
open_url, render_template, serialize_string,
55-
StaticContext)
52+
from MetaSearch.util import (clean_ows_url, get_connections_from_file,
53+
get_ui_class, get_help_url, highlight_xml,
54+
normalize_text, open_url, render_template,
55+
serialize_string, StaticContext)
5656

5757
BASE_CLASS = get_ui_class('maindialog.ui')
5858

@@ -718,7 +718,7 @@ def add_to_ows(self):
718718

719719
# no dups detected or overwrite is allowed
720720
self.settings.beginGroup('/Qgis/connections-%s' % stype[1])
721-
self.settings.setValue('/%s/url' % sname, data_url)
721+
self.settings.setValue('/%s/url' % sname, clean_ows_url(data_url))
722722
self.settings.endGroup()
723723

724724
# open provider window

python/plugins/MetaSearch/util.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from pygments import highlight
4141
from pygments.lexers import XmlLexer
4242
from pygments.formatters import HtmlFormatter
43-
from qgis.PyQt.QtCore import QSettings
43+
from qgis.PyQt.QtCore import QSettings, QUrl
4444
from qgis.PyQt.QtWidgets import QMessageBox
4545
from qgis.PyQt.uic import loadUiType
4646

@@ -167,3 +167,15 @@ def serialize_string(input_string):
167167
value = '%s 1' % input_string
168168

169169
return value
170+
171+
172+
def clean_ows_url(url):
173+
"""clean an OWS URL of added basic service parameters"""
174+
175+
url2 = QUrl(url)
176+
url2.removeEncodedQueryItem('service')
177+
url2.removeEncodedQueryItem('SERVICE')
178+
url2.removeEncodedQueryItem('request')
179+
url2.removeEncodedQueryItem('REQUEST')
180+
181+
return url2.toString()

0 commit comments

Comments
 (0)