Replace library org.apache.sanselan:sanselan:0.97-incubator with org.apache.commons:commons-imaging:1.0-alpha3

This commit is contained in:
Benoit Marty 2022-10-26 12:32:27 +02:00
parent cbb0d4b438
commit 3632e6dc8a
3 changed files with 18 additions and 20 deletions

View file

@ -160,7 +160,7 @@ ext.libs = [
'emojiGoogle' : "com.vanniktech:emoji-google:$vanniktechEmoji" 'emojiGoogle' : "com.vanniktech:emoji-google:$vanniktechEmoji"
], ],
apache : [ apache : [
'commonsImaging' : "org.apache.sanselan:sanselan:0.97-incubator" 'commonsImaging' : "org.apache.commons:commons-imaging:1.0-alpha3"
], ],
sentry: [ sentry: [
'sentryAndroid' : "io.sentry:sentry-android:$sentry" 'sentryAndroid' : "io.sentry:sentry-android:$sentry"

View file

@ -176,7 +176,6 @@ ext.groups = [
'org.apache.ant', 'org.apache.ant',
'org.apache.commons', 'org.apache.commons',
'org.apache.httpcomponents', 'org.apache.httpcomponents',
'org.apache.sanselan',
'org.bouncycastle', 'org.bouncycastle',
'org.ccil.cowan.tagsoup', 'org.ccil.cowan.tagsoup',
'org.checkerframework', 'org.checkerframework',

View file

@ -17,11 +17,11 @@
package org.matrix.android.sdk.internal.session.content package org.matrix.android.sdk.internal.session.content
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.apache.sanselan.Sanselan import org.apache.commons.imaging.Imaging
import org.apache.sanselan.formats.jpeg.JpegImageMetadata import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata
import org.apache.sanselan.formats.jpeg.exifRewrite.ExifRewriter import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter
import org.apache.sanselan.formats.tiff.constants.ExifTagConstants import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants
import org.apache.sanselan.formats.tiff.constants.GPSTagConstants import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.internal.util.TemporaryFileCreator import org.matrix.android.sdk.internal.util.TemporaryFileCreator
@ -46,24 +46,23 @@ internal class ImageExifTagRemover @Inject constructor(
*/ */
suspend fun removeSensitiveJpegExifTags(jpegImageFile: File): File = withContext(coroutineDispatchers.io) { suspend fun removeSensitiveJpegExifTags(jpegImageFile: File): File = withContext(coroutineDispatchers.io) {
val outputSet = tryOrNull("Unable to read JpegImageMetadata") { val outputSet = tryOrNull("Unable to read JpegImageMetadata") {
(Sanselan.getMetadata(jpegImageFile) as? JpegImageMetadata)?.exif?.outputSet (Imaging.getMetadata(jpegImageFile) as? JpegImageMetadata)?.exif?.outputSet
} ?: return@withContext jpegImageFile } ?: return@withContext jpegImageFile
tryOrNull("Unable to remove ExifData") { tryOrNull("Unable to remove ExifData") {
outputSet.removeField(ExifTagConstants.EXIF_TAG_GPSINFO) outputSet.removeField(ExifTagConstants.EXIF_TAG_GPSINFO)
outputSet.removeField(ExifTagConstants.EXIF_TAG_SUBJECT_LOCATION_1) outputSet.removeField(ExifTagConstants.EXIF_TAG_SUBJECT_LOCATION)
outputSet.removeField(ExifTagConstants.EXIF_TAG_SUBJECT_LOCATION_2)
outputSet.removeField(ExifTagConstants.EXIF_TAG_USER_COMMENT) outputSet.removeField(ExifTagConstants.EXIF_TAG_USER_COMMENT)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_ALTITUDE) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_ALTITUDE)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_ALTITUDE_REF) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_ALTITUDE_REF)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_LONGITUDE) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_LONGITUDE_REF) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_DEST_LONGITUDE) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_DEST_LONGITUDE)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_DEST_LONGITUDE_REF) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_DEST_LONGITUDE_REF)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_LATITUDE) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_LATITUDE)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_LATITUDE_REF) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_DEST_LATITUDE) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_DEST_LATITUDE)
outputSet.removeField(GPSTagConstants.GPS_TAG_GPS_DEST_LATITUDE_REF) outputSet.removeField(GpsTagConstants.GPS_TAG_GPS_DEST_LATITUDE_REF)
} ?: return@withContext jpegImageFile } ?: return@withContext jpegImageFile
val scrubbedFile = temporaryFileCreator.create() val scrubbedFile = temporaryFileCreator.create()