openfoodnetwork icon indicating copy to clipboard operation
openfoodnetwork copied to clipboard

[Product Import] Smart quotes (’) handled differently than straight quotes (')

Open audez opened this issue 2 years ago • 0 comments

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

  1. Create an enterprise (shop/hub/profile) with an apostrophe in it (for ex: fredo's farm)
  2. Create a product with an apostrophe in it (for ex: tomates d'amour")
  3. 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
  1. Create a csv file with your product (for ex: bug_apostrophe.csv)
  2. Import the file and see the error fredo’s farm - enterprise could not be found in database
  3. Correct the apostrophe in your file by copy/pasting the straight quote (or change your spreadsheet settings)
  4. Import the file again
  5. See that the product is duplicated

Animated Gif/Screenshot

Enterprise with a quote is not recognized

Screen Shot 2022-08-09 at 22 02 50 Screen Shot 2022-08-09 at 22 02 43

Product with a quote has been duplicated

Screen Shot 2022-08-09 at 19 19 57

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

audez avatar Aug 09 '22 20:08 audez