Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit f9705ffe authored by Arnau Mora's avatar Arnau Mora Committed by GitHub
Browse files

Added handler for properties with null value when inserting (#89)



Fixes #88

* Added handler for properties with null value when inserting

Signed-off-by: default avatarArnau Mora <arnyminer.z@gmail.com>

* Added test for checking ignored attach with invalid encoding

Signed-off-by: default avatarArnau Mora <arnyminer.z@gmail.com>

* Removed test

Signed-off-by: default avatarArnau Mora <arnyminer.z@gmail.com>

* Added test for unknown properties with null value

Signed-off-by: default avatarArnau Mora <arnyminer.z@gmail.com>

* Optimize imports

---------

Signed-off-by: default avatarArnau Mora <arnyminer.z@gmail.com>
Co-authored-by: default avatarRicki Hirner <hirner@bitfire.at>
parent 4b2cea2f
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import org.junit.Assert.*
import java.net.URI
import java.time.Duration
import java.time.Period
import java.util.TimeZone

class AndroidEventTest {

@@ -1269,6 +1268,16 @@ class AndroidEventTest {
        }
    }

    @Test
    fun testBuildUnknownProperty_NoValue() {
        buildEvent(true) {
            unknownProperties += XProperty("ATTACH", ParameterList(), null)
        }.let { result ->
            // The property should not have been added, so the first unknown property should be null
            assertNull(firstUnknownProperty(result))
        }
    }

    private fun firstException(values: ContentValues): ContentValues? {
        val id = values.getAsInteger(Events._ID)
        provider.query(Events.CONTENT_URI.asSyncAdapter(testAccount), null,
+2 −2
Original line number Diff line number Diff line
@@ -9,13 +9,13 @@ import at.bitfire.ical4android.validation.FixInvalidUtcOffsetPreprocessor
import at.bitfire.ical4android.validation.ICalPreprocessor
import io.mockk.mockkObject
import io.mockk.verify
import java.io.InputStreamReader
import java.io.StringReader
import net.fortuna.ical4j.data.CalendarBuilder
import net.fortuna.ical4j.model.Component
import net.fortuna.ical4j.model.component.VEvent
import org.junit.Assert.assertEquals
import org.junit.Test
import java.io.InputStreamReader
import java.io.StringReader

class ICalPreprocessorTest {

+2 −2
Original line number Diff line number Diff line
@@ -4,13 +4,13 @@

package at.bitfire.ical4android

import java.time.ZoneOffset
import java.util.Locale
import net.fortuna.ical4j.model.property.TzOffsetFrom
import org.junit.AfterClass
import org.junit.Assert.assertEquals
import org.junit.BeforeClass
import org.junit.Test
import java.time.ZoneOffset
import java.util.*

class LocaleNonWesternDigitsTest {

+4 −0
Original line number Diff line number Diff line
@@ -990,6 +990,10 @@ abstract class AndroidEvent(
    }

    protected open fun insertUnknownProperty(batch: BatchOperation, idxEvent: Int?, property: Property) {
        if (property.value == null) {
            Ical4Android.log.warning("Ignoring unknown property with null value")
            return
        }
        if (property.value.length > UnknownProperty.MAX_UNKNOWN_PROPERTY_SIZE) {
            Ical4Android.log.warning("Ignoring unknown property with ${property.value.length} octets (too long)")
            return