Skip to content

Commit 66346ea

Browse files
Prevent ShareIntentTextRenderer from escaping chars from HTML
1 parent 9de218e commit 66346ea

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ android {
7979
lint {
8080
abortOnError = false
8181
}
82+
83+
testOptions {
84+
unitTests.isReturnDefaultValues = true
85+
}
8286
}
8387

8488
dependencies {

app/src/main/java/com/readrops/app/util/ShareIntentTextRenderer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class ShareIntentTextRenderer(private val itemWithFeed: ItemWithFeed): KoinCompo
126126
override fun getFilters(): Map<String, Filter> = this@Companion.filters
127127
})
128128
.newLineTrimming(false)
129+
.autoEscaping(false)
129130
.build()
130131
}
131-
}
132+
}

app/src/test/java/com/readrops/app/TemplateTest.kt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ package com.readrops.app
22

33
import com.readrops.app.util.FrenchTypography
44
import com.readrops.app.util.RemoveAuthorFilter
5+
import com.readrops.app.util.ShareIntentTextRenderer
6+
import com.readrops.db.entities.Item
7+
import com.readrops.db.entities.OpenIn
8+
import com.readrops.db.pojo.ItemWithFeed
59
import junit.framework.TestCase.assertEquals
610
import kotlinx.coroutines.test.runTest
711
import org.junit.Test
@@ -33,4 +37,22 @@ class TemplateTest {
3337
assertEquals(" :", FrenchTypography.filter(" :"))
3438
assertEquals(" ;", FrenchTypography.filter(" ;"))
3539
}
36-
}
40+
41+
/** Asserts rendered won't HTML escape */
42+
@Test
43+
fun dontEscape() {
44+
val renderer = ShareIntentTextRenderer(
45+
ItemWithFeed(
46+
Item(title = "\"Title\""),
47+
"",
48+
0,
49+
0,
50+
null,
51+
null,
52+
null,
53+
openIn = OpenIn.EXTERNAL_VIEW
54+
)
55+
)
56+
assertEquals("\"Title\"", renderer.render("{{ title }}"))
57+
}
58+
}

0 commit comments

Comments
 (0)