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 4, 2017
1 parent b2a9a42 commit cd0817b
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 @@ -50,10 +50,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 @@ -719,7 +719,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 PyQt4.QtCore import QSettings
from PyQt4.QtCore import QSettings, QUrl
from PyQt4.QtGui import QMessageBox
from PyQt4.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 cd0817b

Please sign in to comment.