The Insert Field help shows deck and note type names as HTML

Open Beginner friendly
#23,755 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
android, kotlin
Domain
mobile

Research direction

The bug is in the description builders SpecialFields.Deck.buildDescription and SpecialFields.NoteType.buildDescription, which the proposed tests in AnkiDroid/src/test/java/com/ichi2/anki/dialogs/InsertFieldDialogTest.kt call directly. Start by reading where the deck and note type names are placed into the description string and check whether they are passed through HTML parsing. Run InsertFieldDialogTest; done means both new tests pass and the names appear as literal text, such as & and tags, rather than as rendered HTML.

Written by the indexing model from the issue text.

Description

code-scan

Assisted-by: Claude Opus 5.5

[EXISTING] The Insert Field help shows deck and note type names as HTML
Subject: [EXISTING] The Insert Field help shows deck and note type names as HTML

The special field help parses deck, note type and card type names as HTML, so deck "Math & Science" reads as "Math & Science".

⚠️ This issue existed before the PR and should likely be split off into a separate issue.

---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/InsertFieldDialogTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/InsertFieldDialogTest.kt
index eef650669b..b0ba179ba2 100644
--- a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/InsertFieldDialogTest.kt
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/InsertFieldDialogTest.kt
@@ -223,6 +223,24 @@ class InsertFieldDialogTest : RobolectricTest() {
         )
     }
 
+    @Test
+    fun `{{Deck}} description keeps HTML entities in the deck name`() {
+        val metadata = metadata.copy(deck = "Math & Science")
+        assertThat(
+            SpecialFields.Deck.buildDescription(metadata),
+            equalTo("The full deck of the card, including parent decks: ‘Math & Science’"),
+        )
+    }
+
+    @Test
+    fun `{{Type}} description keeps tags in the note type name`() {
+        val metadata = metadata.copy(noteTypeName = "<b>x</b> y")
+        assertThat(
+            SpecialFields.NoteType.buildDescription(metadata),
+            equalTo("The name of the note type: ‘<b>x</b> y’"),
+        )
+    }
+
     @Test
     fun `{{Subdeck}} description if not set`() {
         val metadata = metadata.copy(deck = null)

Found while handling https://github.com/ankidroid/Anki-Android/pull/23697#pullrequestreview-6058429231

Dominant language
Kotlin
Stars
12.3k
Forks
3.1k
Avg merge
2d 1h
Merged PRs (30d)
320

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ankidroid/Anki-Android

All issues in ankidroid/Anki-Android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.