"Show Duplicates" not working

When clicking on an “Show Duplicates” button/alert, no results are shown. No addons enabled.

edit: I original thought this was related the fields having [sound:*], but it occurs with any.

It works for me…

Huh, might be a beta issue then. I’m on 2.1.34 (5a404352).

Works for me on 2.1.34 too.
Do you have the issue with version 2.1.33?

I’m not able to reproduce the problem with [sound:foo.mp3]

No idea how the [sound:…] failure came out (don’t see it at the moment, but I edited cards & templates a lot).

One issue I did find though is that some “show duplicates” queries fail as they use html escapes when the fields don’t, eg. " → "

I can confirm the second issue. I think Anki should store the characters ( " ) and ( ' ) in their HTML-escaped form in notes, like what it does for (<, >, &)

A fix for the second issue:

diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py
index 2a980d03..75263af7 100644
--- a/qt/aqt/editor.py
+++ b/qt/aqt/editor.py
@@ -16,6 +16,7 @@ from typing import Callable, List, Optional, Tuple
 import bs4
 import requests
 from bs4 import BeautifulSoup
+from bs4.formatter import HTMLFormatter  # type: ignore
 import aqt
 import aqt.sound
@@ -1219,7 +1220,13 @@ def reverse_url_quoting(txt, editor):
     return editor.mw.col.media.escapeImages(txt, unescape=True)
+def html_escape(txt, editor):
+    b = BeautifulSoup(txt, "html.parser")
+    return b.decode(formatter=HTMLFormatter(html.escape))

I hope this doesn’t break anything…

1 Like

I fear that may introduce other problems - I think it would be safer just to use the actual field content in the search.

1 Like

Actually. We just have to escape the (") character for search and not HTML-escape it.

diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py
index 2a980d03..086121e9 100644
--- a/qt/aqt/editor.py
+++ b/qt/aqt/editor.py
@@ -493,7 +493,9 @@ class Editor:
         self.web.eval("setBackgrounds(%s);" % json.dumps(cols))
     def showDupes(self):
-        contents = html.escape(stripHTMLMedia(self.note.fields[0]))
+        contents = html.escape(
+            stripHTMLMedia(self.note.fields[0]), quote=False
+        ).replace('"', r"\"")
         browser = aqt.dialogs.open("Browser", self.mw)
             '"dupe:%s,%s"' % (self.note.model()["id"], contents)
1 Like

@nwwt was it only double quotes you were having trouble with?

It did start with me noticing an issue with [sound:…] fields, but the double quotes are the only part I managed to reproduce after copying (edited) the deck into a new profile.

Some more minor unrelated things I don’t want to make a thread for:

  1. Missing space in “Shared Byauthor” string on AnkiWeb
  2. Media references are omitted entirely for the card browser’s list/columns, leading to nothing being shown if eg. an audio field is selected as sort field (unlike with Advanced Browser’s custom field column, which shows the filename).

(Also, the issues of overlong fields being copied into AnkiWeb’s card preview and webp/svg not counted as images remain, but I already reported that on the old forum.)

Where is the string with the missing space?

It’s shown as html title when clicking on “The author has shared # other item(s)”, like here. On second thought, I guess it’s not a fixed string but just the path segments put together.

Ah, I see. Thanks, will fix.

I didn’t want to open a new topic because my problem seems to be the same as this here but I’m currently on the latest stable version (Version 2.1.35 (84dcaa86)) and when I click the “Show Duplicates” button when adding a note it brings me to the browser with the search field filled (for example: “dupe:1432470439634,เรียก”), but it doesn’t show any card in the browser.

This could happen if there is some embedded HTML in the note that Anki handles incorrectly.
The issue is supposed to be fixed in the latest beta. If you want, You can try the beta and report if that fixes the problem.

I just tried the latest beta (Version ⁨2.1.36 (c1d15a8e)⁩) and it’s still not working for me.
I actually don’t have any html in my notes. Only plain text.
I also tried “Check Database” with no results.

There could be some HTML code embedded in the note though it may not look like that since Anki stores notes as HTML.
Could you open the HTML editor (using Ctrl+Shift+X when in the note editor) and copy its content and paste it here?
Make sure to enclose the pasted text in backticks (`) like this:


I have 4 different fields and when I check the HTML editor for each field this is what I get

  1. Thai: เรียก
  2. Pronunciation: riiak<sup>F</sup>
  3. Audio: [sound:E132517.mp3]<br>
  4. English: to call [for something]

So the pronunciation and audio fields contain HTML then?