Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guards against creating very large UImages from SVGs #818

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions openHAB.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -414,7 +412,6 @@
DAC9395422B00E7600C5F423 /* XCTestCaseExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTestCaseExtension.swift; sourceTree = "<group>"; };
DAC9AF4624F9669F006DAE93 /* ObservableOpenHABWidgetExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ObservableOpenHABWidgetExtension.swift; sourceTree = "<group>"; };
DAC9AF4824F966FA006DAE93 /* LazyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyView.swift; sourceTree = "<group>"; };
DACB636127D3FC6500041931 /* error.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = error.png; sourceTree = "<group>"; };
DAD488B2287DDDFE00414693 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Interface.strings; sourceTree = "<group>"; };
DAD488B3287DDDFE00414693 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = Resources/nb.lproj/Intents.strings; sourceTree = "<group>"; };
DAD488B4287DDDFF00414693 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -847,6 +844,7 @@
children = (
DFB2624518830A3600D3244D /* Images.xcassets */,
DACB636127D3FC6500041931 /* error.png */,
DF4B84061885AE0E00F34902 /* blankicon.png */,
);
name = Images;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
);
Expand Down Expand Up @@ -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 */,
Expand Down
5 changes: 4 additions & 1 deletion openHAB/OpenHABSitemapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Binary file removed openHAB/error.png
Binary file not shown.
Loading