Skip to content

Commit

Permalink
MetaSearch: clean OWS URL when adding from search (http://hub.qgis.or…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Mar 5, 2017
1 parent 5a962e8 commit 19e6015
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python/plugins/MetaSearch/dialogs/maindialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
from MetaSearch.dialogs.newconnectiondialog import NewConnectionDialog
from MetaSearch.dialogs.recorddialog import RecordDialog
from MetaSearch.dialogs.xmldialog import XMLDialog
from MetaSearch.util import (get_connections_from_file, get_ui_class,
get_help_url, highlight_xml, normalize_text,
open_url, render_template, serialize_string,
StaticContext)
from MetaSearch.util import (clean_ows_url, get_connections_from_file,
get_ui_class, get_help_url, highlight_xml,
normalize_text, open_url, render_template,
serialize_string, StaticContext)

BASE_CLASS = get_ui_class('maindialog.ui')

Expand Down Expand Up @@ -723,7 +723,7 @@ def add_to_ows(self):

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

# open provider window
Expand Down
13 changes: 13 additions & 0 deletions python/plugins/MetaSearch/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from pygments import highlight
from pygments.lexers import XmlLexer
from pygments.formatters import HtmlFormatter
from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtWidgets import QMessageBox
from qgis.PyQt.uic import loadUiType

Expand Down Expand Up @@ -171,3 +172,15 @@ def serialize_string(input_string):
value = '%s 1' % input_string

return value


def clean_ows_url(url):
"""clean an OWS URL of added basic service parameters"""

url2 = QUrl(url)
url2.removeEncodedQueryItem('service')
url2.removeEncodedQueryItem('SERVICE')
url2.removeEncodedQueryItem('request')
url2.removeEncodedQueryItem('REQUEST')

return url2.toString()

0 comments on commit 19e6015

Please sign in to comment.