Skip to content

Commit

Permalink
handle percent-encoded font references in SLD (fix #27263)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and github-actions[bot] committed Jan 28, 2022
1 parent 572cb3a commit d6410f2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/symbology/qgssymbollayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2923,7 +2923,7 @@ bool QgsSymbolLayerUtils::onlineResourceFromSldElement( QDomElement &element, QS
if ( onlineResourceElem.isNull() )
return false;

path = onlineResourceElem.attributeNS( QStringLiteral( "http://www.w3.org/1999/xlink" ), QStringLiteral( "href" ) );
path = QUrl::fromPercentEncoding( onlineResourceElem.attributeNS( QStringLiteral( "http://www.w3.org/1999/xlink" ), QStringLiteral( "href" ) ).toUtf8() );

const QDomElement formatElem = element.firstChildElement( QStringLiteral( "Format" ) );
if ( formatElem.isNull() )
Expand Down
9 changes: 9 additions & 0 deletions tests/src/python/test_qgssymbollayer_readsld.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,15 @@ def testSymbolSize(self):
self.assertEqual(unit, QgsUnitTypes.RenderPixels)
self.assertEqual(size, sld_size_px)

# test percent encoding for QgsFontMarkerSymbolLayer
sld = 'symbol_layer/QgsFontMarkerSymbolLayerPercentEncoding.sld'
mFilePath = os.path.join(TEST_DATA_DIR, sld)
layer.loadSldStyle(mFilePath)

sl = layer.renderer().symbol().symbolLayers()[0]
self.assertTrue(isinstance(sl, QgsFontMarkerSymbolLayer))
self.assertEqual(sl.fontFamily(), 'MapInfo Miscellaneous')

def testSymbolSizeAfterReload(self):
# create a layer
layer = createLayerWithOnePoint()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:se="http://www.opengis.net/se">
<NamedLayer>
<se:Name>022cs000</se:Name>
<UserStyle>
<se:Name>022cs000</se:Name>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>Single symbol</se:Name>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<OnlineResource xlink:type="simple" xlink:href="ttf://MapInfo%20Miscellaneous"/>
<Format>ttf</Format>
<se:MarkIndex>77</se:MarkIndex>
<se:Fill>
<se:SvgParameter name="fill">#000000</se:SvgParameter>
</se:Fill>
</se:Mark>
<se:Size>6.23</se:Size>
<se:Rotation>
<ogc:Literal>3</ogc:Literal>
</se:Rotation>
</se:Graphic>
</se:PointSymbolizer>
</se:Rule>
</se:FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

0 comments on commit d6410f2

Please sign in to comment.