From d3efa5338597b7f8d5e7d4c7c18b94283f04a868 Mon Sep 17 00:00:00 2001 From: Dan Cunningham Date: Sun, 15 Sep 2024 10:42:55 -0700 Subject: [PATCH] Guards against creating very large UImages from SVGs (#818) * Guards against creating very large UImages from SVGs Fixes #817 Signed-off-by: Dan Cunningham * remove error.png, use sys icon Signed-off-by: Dan Cunningham --------- Signed-off-by: Dan Cunningham --- openHAB.xcodeproj/project.pbxproj | 6 +----- openHAB/OpenHABSitemapViewController.swift | 5 ++++- openHAB/error.png | Bin 653 -> 0 bytes 3 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 openHAB/error.png diff --git a/openHAB.xcodeproj/project.pbxproj b/openHAB.xcodeproj/project.pbxproj index 1cb31b6c3..522d2240a 100644 --- a/openHAB.xcodeproj/project.pbxproj +++ b/openHAB.xcodeproj/project.pbxproj @@ -123,8 +123,6 @@ DAC9395522B00E7600C5F423 /* XCTestCaseExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC9395422B00E7600C5F423 /* XCTestCaseExtension.swift */; }; DAC9AF4724F9669F006DAE93 /* ObservableOpenHABWidgetExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC9AF4624F9669F006DAE93 /* ObservableOpenHABWidgetExtension.swift */; }; DAC9AF4924F966FA006DAE93 /* LazyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC9AF4824F966FA006DAE93 /* LazyView.swift */; }; - DACB636227D3FC6500041931 /* error.png in Resources */ = {isa = PBXBuildFile; fileRef = DACB636127D3FC6500041931 /* error.png */; }; - DACB636327D3FC6500041931 /* error.png in Resources */ = {isa = PBXBuildFile; fileRef = DACB636127D3FC6500041931 /* error.png */; }; DAEAA89D21E6B06400267EA3 /* ReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEAA89C21E6B06300267EA3 /* ReusableView.swift */; }; DAEAA89F21E6B16600267EA3 /* UITableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEAA89E21E6B16600267EA3 /* UITableView.swift */; }; DAF0A28B2C56E3A300A14A6A /* RollershutterCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAF0A28A2C56E3A300A14A6A /* RollershutterCell.swift */; }; @@ -414,7 +412,6 @@ DAC9395422B00E7600C5F423 /* XCTestCaseExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTestCaseExtension.swift; sourceTree = ""; }; DAC9AF4624F9669F006DAE93 /* ObservableOpenHABWidgetExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObservableOpenHABWidgetExtension.swift; sourceTree = ""; }; DAC9AF4824F966FA006DAE93 /* LazyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyView.swift; sourceTree = ""; }; - DACB636127D3FC6500041931 /* error.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = error.png; sourceTree = ""; }; DAD488B2287DDDFE00414693 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Interface.strings; sourceTree = ""; }; DAD488B3287DDDFE00414693 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = Resources/nb.lproj/Intents.strings; sourceTree = ""; }; DAD488B4287DDDFF00414693 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Localizable.strings; sourceTree = ""; }; @@ -847,6 +844,7 @@ children = ( DFB2624518830A3600D3244D /* Images.xcassets */, DACB636127D3FC6500041931 /* error.png */, + DF4B84061885AE0E00F34902 /* blankicon.png */, ); name = Images; sourceTree = ""; @@ -1259,7 +1257,6 @@ 6557AF902C0241C10094D0C8 /* PrivacyInfo.xcprivacy in Resources */, DA07751B2346705F0086C685 /* Assets.xcassets in Resources */, 938BF9D524EFD5B100E6B52F /* Localizable.strings in Resources */, - DACB636327D3FC6500041931 /* error.png in Resources */, DA0775192346705D0086C685 /* Interface.storyboard in Resources */, 932602EE2382892B00EAD685 /* Assets.xcassets in Resources */, ); @@ -1288,7 +1285,6 @@ 938BF9C424EFCB9F00E6B52F /* Main.storyboard in Resources */, DA817E7A234BF39B00C91824 /* CHANGELOG.md in Resources */, DA4D4DB5233F9ACB00B37E37 /* README.md in Resources */, - DACB636227D3FC6500041931 /* error.png in Resources */, DA88F8C622EC377200B408E5 /* ReleaseNotes.md in Resources */, DFDF45311932042B00A6E581 /* legal.rtf in Resources */, 656916D91FCB82BC00667B2A /* GoogleService-Info.plist in Resources */, diff --git a/openHAB/OpenHABSitemapViewController.swift b/openHAB/OpenHABSitemapViewController.swift index 92b79978e..1a003790f 100644 --- a/openHAB/OpenHABSitemapViewController.swift +++ b/openHAB/OpenHABSitemapViewController.swift @@ -46,9 +46,12 @@ struct OpenHABImageProcessor: ImageProcessor { let svgkSourceNSData = SVGKSourceNSData.source(from: data, urlForRelativeLinks: nil) let parseResults = SVGKParser.parseSource(usingDefaultSVGKParser: svgkSourceNSData) if parseResults?.parsedDocument != nil, let image = SVGKImage(parsedSVG: parseResults, from: svgkSourceNSData), image.hasSize() { + if image.size.width > 1000 || image.size.height > 1000 { + return UIImage(systemSymbol: .exclamationmarkTriangle).withTintColor(.orange) + } return image.uiImage } else { - return UIImage(named: "error.png") + return UIImage(systemSymbol: .exclamationmarkTriangle).withTintColor(.orange) } default: return Kingfisher.DefaultImageProcessor().process(item: item, options: KingfisherParsedOptionsInfo(KingfisherManager.shared.defaultOptions)) diff --git a/openHAB/error.png b/openHAB/error.png deleted file mode 100644 index 68bbff2256ca215cf00a065071a045fd8344ffcb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 653 zcmV;80&@L{P)xuy4hXCh<0Oy1N=Y#;~gaGD(0Oy1N=7a#|g8=`f z0RR90<$?g}jScpg0R5r>`kny$?b-V0&hDyC_}#hn&YSYRdFquS{r2tIaieko000tn zQchC<$@f?N9WV9t3+keZxIox>XEf#r`v3p|$4Nv%R9M69mfg03AP|K!u|d<)Nx=Tk z`#T^Nw27_Hp~Htd$Rh#U zHTGI>d*7}S za5au9Ukm$h-z4BhjH#TpGT$3h$j=gRHqQ$G98-XMXHI3axQa&C?h?SvZ0Tn1ahhY; zN1O9x`*S!P+2rv3qDsg#h1kh#gZV|3f)!)3ldi-w-SWZ;(!P^!Ho(28YDbXD zPC9c(z}AbaNd1(|RL8k%BrFSOWm{=mC|y)?5G*Sb$D2O;$nGRpy17=-EMQ`#@o&Np zU@ofC`2e#3Bi%CB4K4w6D=UKG04?2i@W$;K8;x{xTIeCJrZR6aQt(HBk6+<22V8`g n3qH=nCV@6sP{sX+|A+bocy4;M(Bgn~00000NkvXXu0mjfl?gEK