openfoodfacts / power-user-script

User script for your browser, to empower Open Food Facts contribution
GNU Affero General Public License v3.0
12 stars 5 forks source link

List mode ingredients editor truncates ingredients containing a semi-colon (;) or ampersand (&) #36

Closed svensven closed 3 years ago

svensven commented 3 years ago

If the ingredients list has a semi-colon or ampersand in it, the saved ingredients will end there, as they are URL parameter separators and indicate the end of the ingredients_text_fr parameter.

e.g. https://fr.openfoodfacts.org/cgi/product_jqm2.pl?code=20292867&ingredients_text_fr=Spécialités céréalières cuites 30% (eau, semoule de blé dur, blanc d'oeuf, sel), Salade 16%, Vinaigrette allégée en matières grasses'; au fromage blanc 15 % (eau, huile de colza 3,8%, fromage blanc 3%...

Looking at the record in the proper editor, the saved ingredients stop at matières grasses'.

svensven commented 3 years ago

The ingredients text should probably go through encodeURIComponent() before being added to a URL.