ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.73k stars 2.24k forks source link

[BUG]: <svg> not displayed nor accepted as valid input #17440

Closed natema closed 1 week ago

natema commented 1 week ago

Checked for duplicates?

Does it also happen in the desktop version?

What are the steps to reproduce this bug?

Create a new card with front

<svg width="200" height="100">
  <rect width="200" height="100" fill="blue" />
</svg>

Expected behaviour

Debug info

AnkiDroid Version = 2.19.1 (6953d60532ee2762d29b06fd1d76e69203ad8455)

Backend Version = 0.1.43-anki24.06.3 (24.06.3 d678e39350a2d243242a69f4e22f5192b04398f2)

Android Version = 13 (SDK 33)

ProductFlavor = play

Manufacturer = samsung

Model = SM-T976B

Hardware = qcom

Webview User Agent = Mozilla/5.0 (Linux; Android 13; SM-T976B Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/130.0.6723.107 Safari/537.36

ACRA UUID = d3f4901a-c6f6-453e-9e92-03961a0d8f39

FSRS = 0.6.4 (Enabled: false)

Crash Reports Enabled = true

(Optional) Anything else you want to share?

I wasn't able to determine if this issue is related to #17029 or https://github.com/ankidroid/Anki-Android/issues/3250.

In Anki Desktop, the svg is correctly previewed, but it seems that Anki is still ignoring the svg, since if the front only contains the svg element Anki says that the card is empty when the user tried to create it. Moreover, the two following cards are considered the same:

Research

welcome[bot] commented 1 week ago

Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing

david-allison commented 1 week ago

Reproduced... cool!

Thanks so much for this one!

natema commented 1 week ago

I just noticed that, while the preview works in Anki Desktop, the svg element still appears to be entirely ignored. I edited the "Anything else you want to share?" section in the issue description. At this point it's borderline to say that it's not an Anki Desktop bug. I will create an issue there as well and link it here.

david-allison commented 1 week ago

https://github.com/ankidroid/Anki-Android/labels/upstream-issue. Please report it on the forums

col.backend.noteFieldsCheck(this.toBackendNote()).state == NoteFieldsCheckResponse.State.EMPTY

Screenshot from Anki Desktop Version ⁨24.06.3 (d678e393)⁩ showing the same issue

Image

Additional info: executed noteFieldsCheck with data

# anki.notes.Note@21a7e6b7
fields: "<svg width=\"200\" height=\"100\"><br>  <rect width=\"200\" height=\"100\" fill=\"blue\" /><br></svg>"
fields: ""
fields: ""
guid: "o#L2Vu%%uy"
id: 0
notetype_id: 1731502348910

I'm closing this as it's an issue with Anki Desktop (as per the screenshot), but please feel free to respond if I'm mistaken

david-allison commented 1 week ago

Thanks so much for the detailed report! Made this one really easy to diagnose

natema commented 1 week ago

It seems to me that there still is an issue with AnkiDroid per se: the Desktop version ignores the svgs to determine if the card is empty or unique, but correctly displays them. For example, I can create such a card: Front

What color is this?
<svg width="200" height="100">
  <rect width="200" height="100" fill="blue" />
</svg>

Back

Blue

The svg element is correctly shown on Anki Desktop, while on AnkiDroid, the svg square is not shown.

david-allison commented 1 week ago
![Image](https://github.com/user-attachments/assets/9db5f184-6f9c-4d8c-89f7-5f1ee11fd5f5)

Can be fixed with:


natema commented 1 week ago

Thanks a lot! Here's the issue in the forum https://forums.ankiweb.net/t/content-of-svg-elements-is-ignored-in-determining-if-the-card-is-unique/51915