[Windows (only?)] - Anki crashes when creating profile containing newline characters


Recently a user reported she had errors when creating a profile containing the new line character \n. See issue 4601 for the original report.

I tried to reproduce the error using Linux but I was not able to do so. I suppose Mac and other UNIX-like systems won’t produce errors either.

Here is what I did to create a profile name containing the newline character:

  1. Write the profile name in another place (external editor, for instance)
  2. Paste the profile name in the dialog window that prompt for name to create a new profile

In Linux this profile is fully functional, however, the user (using Windows 7) reported she couldn’t edit, open or even remove the problematic profile.

I’m just posting it here, maybe a bug not known yet?

My OS and Anki info:

  • Linux 5.9.1-arch1-1
  • Anki 2.1.35 (built from source)

PS: Does someone know how to cross link existing issues in this forum? (something similar to github’s feature that enables one to type #<num_of_issue> to create a link to an existing issue in the repo. - I needed to copy the whole url to reference the original report…)


Thanks for the translation. I can reproduce this on Win 10 with Windows, Macintosh and Unix line endings.
However, the bug is definitely accepting control characters in profile names, rather than the consequences.

I think it’s hilarious that people try to put line breaks into their profile names while I was too scared to even use spaces until now. :sweat_smile:


Previously users were (perhaps accidentally) adding a trailing space to profile names, which broke on Windows. Anki now prevents that, but you’ve found another way to break things :slight_smile: Rumo’s right in that this needs to filtered out at profile creation/renaming time - no control characters should be allowed.

1 Like

I see… :laughing:

Well, at least this fix seems easy, doesn’t it?
(I’m totally lost reading the source code for now - I’m just a junior “dev”, but I think it just need a profileName.strip().replace("\n", "") or something similar.)

By the way, I had to delete my prefs21.db in order to get rid of the faulty profiles. As far as I can tell, only some add-on settings and window geometries have been lost. But if anyone wants to replicate this, be careful! :wink:

1 Like