openfoodnetwork
openfoodnetwork copied to clipboard
[Product Import] Smart quotes (’) handled differently than straight quotes (')
Description
When typing an apostrophe in the admin interface, the quote is straight: fredo's farm But when you create a product file (a csv file for example), the quote can be straight or smart: fredo’s farm (this will depend on the formatting you choose in your spreadsheet software.)
This causes troubles when you import the product file, notably:
- If the enterprise name has a quote in it (ex: fredo's farm), and you import a file with the enterprise name including a smart quote (fredo’s farm), it will cause the error:
fredo’s farm - enterprise could not be found in database
- If you update a product that has a quote in it (ex: tomates d'a mour), it will be duplicated - as the apostrophe is recognized as a different character, thus the product name is not considered the same.
Expected Behavior
Whether the quote is straight or smart should not make any difference.
Actual Behaviour
The smart and straight quotes are not recognized as the same.
Steps to Reproduce
- Create an enterprise (shop/hub/profile) with an apostrophe in it (for ex: fredo's farm)
- Create a product with an apostrophe in it (for ex: tomates d'amour")
- Open a spreadsheet software and activate the smart quote
- in Open Office Calc: Tools > AutoCorrect Options > Localized Options > Single quotes/Double quotes > Replace: ON
- in Numbers (Mac): Edit > Substitutions > Smart quotes
- Create a csv file with your product (for ex: bug_apostrophe.csv)
- Import the file and see the error
fredo’s farm - enterprise could not be found in database
- Correct the apostrophe in your file by copy/pasting the straight quote (or change your spreadsheet settings)
- Import the file again
- See that the product is duplicated
Animated Gif/Screenshot
Enterprise with a quote is not recognized
Product with a quote has been duplicated
Workaround
Realize that the smart quote is the problem, and replace it in your file
Severity
bug-s5: we can live with it, only a few users impacted