diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt index 9e6c7805a6dc..2ce8b04953df 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt @@ -340,7 +340,7 @@ fun parseVideos(text: String, mediaDir: String): String { @NotInLibAnki @VisibleForTesting fun parseSourcesToFileScheme(content: String, mediaDir: String): String { - val doc = Jsoup.parse(content) + val doc = Jsoup.parseBodyFragment(content) doc.outputSettings(OutputSettings().prettyPrint(false)) fun replaceWithFileScheme(tag: String, attr: String): Boolean { diff --git a/AnkiDroid/src/test/java/com/ichi2/libanki/TemplateManagerTest.kt b/AnkiDroid/src/test/java/com/ichi2/libanki/TemplateManagerTest.kt index 9e7780216610..95d82bf0de4e 100644 --- a/AnkiDroid/src/test/java/com/ichi2/libanki/TemplateManagerTest.kt +++ b/AnkiDroid/src/test/java/com/ichi2/libanki/TemplateManagerTest.kt @@ -133,6 +133,33 @@ class TemplateManagerTest { assertEquals("""""", result) } + @Test + fun `parseSourcesToFileScheme - mixed script`() { + @Language("HTML") + val input = """ + + + + + hughes and kisses + """ + + @Language("HTML") + val expectedResult = """ + + + + + hughes and kisses + """ + val result = parseSourcesToFileScheme(input, "/storage/emulated/0/15773/collection.media") + assertEquals(expectedResult, result) + } + /*********************************************************************************************** * [parseVideos] tests **********************************************************************************************/