Skip to content

Commit

Permalink
Merge pull request #4216 from tomkralidis/issue-16261-2.18
Browse files Browse the repository at this point in the history
 MetaSearch: clean OWS URL when adding from search #4215
  • Loading branch information
tomkralidis authored Mar 4, 2017
2 parents 4f3719c + 876a84d commit 067df25
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 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 @@ -49,10 +49,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 @@ -718,7 +718,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
14 changes: 13 additions & 1 deletion python/plugins/MetaSearch/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from pygments import highlight
from pygments.lexers import XmlLexer
from pygments.formatters import HtmlFormatter
from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtCore import QSettings, QUrl
from qgis.PyQt.QtWidgets import QMessageBox
from qgis.PyQt.uic import loadUiType

Expand Down Expand Up @@ -167,3 +167,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 067df25

Please sign in to comment.