From 4b4eecf81012d701f61cdfdb14e219f3ac657722 Mon Sep 17 00:00:00 2001 From: Clemens Date: Fri, 19 Aug 2022 08:38:48 +0200 Subject: [PATCH] Check TileSource.GetUri arguments --- MapControl/Shared/BingMapsTileSource.cs | 3 ++- MapControl/Shared/TileSource.cs | 4 ++-- MapControl/Shared/WmtsTileSource.cs | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MapControl/Shared/BingMapsTileSource.cs b/MapControl/Shared/BingMapsTileSource.cs index 9dda1c68..500b3827 100644 --- a/MapControl/Shared/BingMapsTileSource.cs +++ b/MapControl/Shared/BingMapsTileSource.cs @@ -12,7 +12,8 @@ namespace MapControl { Uri uri = null; - if (UriFormat != null && Subdomains != null && Subdomains.Length > 0 && zoomLevel > 0) + if (UriFormat != null && Subdomains != null && Subdomains.Length > 0 && + x >= 0 && y >= 0 && zoomLevel > 0) { var subdomain = Subdomains[(x + y) % Subdomains.Length]; var quadkey = new char[zoomLevel]; diff --git a/MapControl/Shared/TileSource.cs b/MapControl/Shared/TileSource.cs index 721ca250..9c7f86a6 100644 --- a/MapControl/Shared/TileSource.cs +++ b/MapControl/Shared/TileSource.cs @@ -32,7 +32,7 @@ namespace MapControl get => uriFormat; set { - uriFormat = value?.Replace("{c}", "{s}"); // for backwards compatibility since 5.4.0 + uriFormat = value; if (Subdomains == null && uriFormat != null && uriFormat.Contains("{s}")) { @@ -53,7 +53,7 @@ namespace MapControl { Uri uri = null; - if (UriFormat != null) + if (UriFormat != null && x >= 0 && y >= 0 && zoomLevel >= 0) { var uriString = UriFormat .Replace("{x}", x.ToString()) diff --git a/MapControl/Shared/WmtsTileSource.cs b/MapControl/Shared/WmtsTileSource.cs index 8891d8cf..e0069103 100644 --- a/MapControl/Shared/WmtsTileSource.cs +++ b/MapControl/Shared/WmtsTileSource.cs @@ -15,9 +15,8 @@ namespace MapControl Uri uri = null; if (UriFormat != null && - TileMatrixSet != null && - zoomLevel >= 0 && - zoomLevel < TileMatrixSet.TileMatrixes.Count) + TileMatrixSet != null && TileMatrixSet.TileMatrixes.Count > zoomLevel && + x >= 0 && y >= 0 && zoomLevel >= 0) { uri = new Uri(UriFormat .Replace("{TileMatrixSet}", TileMatrixSet.Identifier)