Skip to content

Commit

Permalink
Merge pull request #88 from jgrocha/fix-utf8-sld
Browse files Browse the repository at this point in the history
Fixes #44 #87 #71
  • Loading branch information
volaya authored Jan 24, 2019
2 parents e0842a6 + 2bab791 commit b0658f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions geoserverexplorer/gui/gsnameutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@

# noinspection PyPep8Naming
def xmlNameFixUp(name):
# TODO: handle bad unicode characters, too
n = name.replace(u' ', u'_') # doesn't hurt to always do this
if not isinstance(name, unicode):
name = name.decode('utf-8', errors='ignore')
n = unicode(unicodedata.normalize('NFKD', name).encode('ascii','ignore'))
n = re.sub('[ /\\\\]', '_', n)
if not xmlNameIsValid(n) and not n.startswith(u'_'):
rx = QRegExp(r'^(?=XML|\d|\W).*', Qt.CaseInsensitive)
if rx.exactMatch(n):
Expand Down
5 changes: 3 additions & 2 deletions geoserverexplorer/qgis/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ def publishStyle(self, layer, overwrite = True, name = None):
layer = layers.resolveLayer(layer)
sld, icons = getGsCompatibleSld(layer)
if sld is not None:
name = name if name is not None else layer.name()
name = name.replace(" ", "_")
name = name if name is not None else xmlNameFixUp(layer.name())
if layer.name() != name:
sld = sld.replace(layer.name(), name)
self.uploadIcons(icons)
self.catalog.create_style(name, sld, overwrite)
return sld
Expand Down

0 comments on commit b0658f7

Please sign in to comment.