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

fix: UIImage was wrongfully detected with files containing an image #95

Merged
merged 1 commit into from
Jan 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
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import InfomaniakDI

/// Extending NSItemProvider for detecting file type, business logic.
public extension NSItemProvider {
/// image identifiers supported by the app
/// image file identifiers supported by the app
private static let imageUTIIdentifiers = [
UTI.image.identifier,
UTI.jpeg.identifier,
UTI.tiff.identifier,
UTI.gif.identifier,
Expand Down Expand Up @@ -87,13 +86,13 @@ public extension NSItemProvider {
return .isText
} else if hasItemConformingToAnyOfTypeIdentifiers(Self.imageUTIIdentifiers) {
return .isImageData
} else if registeredTypeIdentifiers.count == 1 &&
registeredTypeIdentifiers.first == UTI.image.identifier {
return .isUIImage
} else if hasItemConformingToAnyOfTypeIdentifiers(Self.directoryUTIIdentifiers) {
return .isDirectory
} else if hasItemConformingToAnyOfTypeIdentifiers(Self.compressedUTIIdentifiers) {
return .isCompressedData(identifier: typeIdentifier)
} else if registeredTypeIdentifiers.count == 1 &&
registeredTypeIdentifiers.first == UTI.image.identifier {
return .isUIImage
} else {
return .isMiscellaneous(identifier: typeIdentifier)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ public struct UTI: RawRepresentable {

public static let webArchive = UTI(rawValue: kUTTypeWebArchive)

/// Typical for UIImage
public static let image = UTI(rawValue: kUTTypeImage)

public static let jpeg = UTI(rawValue: kUTTypeJPEG)
Expand Down
Loading