chiefwigms / picobrew_pico

MIT License
149 stars 63 forks source link

Restrict Characters for use as Recipe Name #196

Closed tmack8001 closed 3 years ago

tmack8001 commented 3 years ago

Some devices (C/S/Pro) allow special characters like expanded ascii... While other devices (Z) fail hard when seeing characters like ö.

Given users will create recipes likely with either a beer name or a style name like "Kölsch" we should prevent recipes both on server input (web UI) and user input (json file parsing) to prevent machines from reporting a server error.

At this point I'm not familiar with the character limitations to our devices so would initially just limit to a-zA-Z0-9 and a few special characters like - _ & + " " and maybe a few more. Should test with Z and Pico to make sure those special characters are allowed and go from there.

Anyone else know of valid character sets for the devices can comment here.

tmack8001 commented 3 years ago

Found that when a recipe uses "#" this causes parsing issues in the brew session parsing due to the metadata assumed to be separated by "#" in the filename.

To get around this issue and to allow "#" in recipe titles I've decided to encode/decode into html component / unicode sequences.

patrickmoineau commented 3 years ago

I experienced an issue today, which I assume was related to special characters. I had a step, foolishly, named: 60 min - Columbus/Tomahawk/Zeus (CTZ)

I'm guessing it didn't like the / but could have also been the ( and ). Going to do some testing tonight with the characters I had issues with.

Also note I made the JSON recipe file and then uploaded it via SFTP.

Edit: Was on a Zymatic.

tmack8001 commented 3 years ago

Ah yes step names likely also have limitations on both the server and the device interface.

Specifically step names I believe are limited to 20 something characters. There are a bunch of "longstepnames" in the Z firmware, the length supported for step names are different for each device I'm sure.

I'd recommend just adding "Hop 1" as the step name and adding the details of the style into the notes (but honestly just track that else where 😄 )

tmack8001 commented 3 years ago

I've added limitations to step names, though recipe names are still fully within the control of the user. This will be a game of whack a mole I'm sure.

cgalpin commented 3 years ago

I was thinking it might be useful to show people a warning when they go over, so at least they know. At least on my PicoS, recipe names would wrap after 21-122 chars iirc

tmack8001 commented 3 years ago

I did similar to this for step names, sure we could do similar for Recipes as well 🤷‍♂️ https://github.com/chiefwigms/picobrew_pico/pull/263/files

cgalpin commented 3 years ago

My preference would be not to stop them entering something longer as long as it doesn’t cause problems with the equipment or something. Just help/warn the unsuspecting or forgetful :)