kelciour / edit-field-during-review

3 stars 1 forks source link

Does not work if there are quotes in the field name #3

Closed BlueGreenMagick closed 5 years ago

BlueGreenMagick commented 5 years ago

If your note type has quotes in the field name, the addon does not generate the correct html. For example, if one of the field name is Front' then the generated html contains[data-field='Front''] so Anki fails to display the card.

BlueGreenMagick commented 5 years ago

I had been tackling this issue, and found out that backslashes cannot be used to escape quotes in html attributes. Nor can the html entity be used, because it seems that semicolons cannot be used either. Although I do not like the solution, I think quotes will have to be replaced by a string of long semi-random letters that will not be used by anyone as field name. Unless there is a better idea?

Edit: Found out that html entities do work in attributes.

BlueGreenMagick commented 5 years ago

Created a pull request that fixes this issue: #4

kelciour commented 5 years ago

Thank you very much for a very detailed report! I've added maybe a temporarily commit on GitHub to fix it. My initial solution with html encoding was similar to yours, but actually worse, and as an alternative I ended up with Base64 encoding.