chiefwigms / picobrew_pico

MIT License
149 stars 63 forks source link

Pico_Recipes Download .json button and save buttons are broken #212

Closed rampantoctopus closed 3 years ago

rampantoctopus commented 3 years ago

It appears that the save and download buttons in the Pico recipes have been broken -- download now opens and collapses the recipe details (and doesn't not download the .json file) and the save button doesn't seem to do anything.

tmack8001 commented 3 years ago

Ah yup this is only an issue if the IBU or ABV contains a decimal... I messed that up yesterday in adding the edit recipe experience for ya. Sorry bout that!

  File "/<>/picobrew_pico/app/main/routes_frontend.py", line 390, in update_pico_recipe
    recipe.update_recipe(filename, update_recipe)
  File "/<>/picobrew_pico/app/main/recipe_parser.py", line 321, in update_recipe
    self.abv = int(recipe.get('abv', self.abv))
ValueError: invalid literal for int() with base 10: '6.6'
tmack8001 commented 3 years ago

Though not sure why the download isn't working for you, I've been able to reliably get that to work here.

When opening devtools do you see any warnings or errors?

tmack8001 commented 3 years ago

https://github.com/chiefwigms/picobrew_pico/pull/213 should resolve that issue with the save

rampantoctopus commented 3 years ago

Though not sure why the download isn't working for you, I've been able to reliably get that to work here.

When opening devtools do you see any warnings or errors?

Ok, that's interesting-- the download button works for other files, but specifically the download on Annie's London Ale doesn't work-- I've tried a bunch of other .json files both with and without making changes to the comments field, both with and without graphics and it's just Annie's... really bad luck?

When working with Annie's London Ale: Download button causes: SyntaxError: Unexpected identifier 's'. Expected ')' to end an argument list. Save button causes: [Error] Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR) (update_pico_recipe, line 0)

tmack8001 commented 3 years ago

Ah yeah... that ' (single quote) is breaking out of the container and causing a problem... we don't do a great job at validating user input cause the worst damage you do is screw up your local hardware there is no "centralized server to hack".

tmack8001 commented 3 years ago

here is the offending javascript/html

<button class="btn btn-sm btn-primary float-right mr-5" type="button" id="bdownload_182c5e16713041" onclick="event.stopPropagation();event.preventDefault();download_recipe('182c5e16713041', 'Annie's Ale');">
                    <i class="fas fa-download"></i>
                </button>

to make it more clear

'Annie's Ale'

image

rampantoctopus commented 3 years ago

Is it just the .json file name or is the title inside the .json file also a problem? If it's just the file name, I could rename the five or so recipes in the library that cross the line:

"Mowin' Time," "Annie's London," "Brew_Free!_or_Die_IPA," "Pike_Monk's_Uncle_Tripel," and "Poçao_da_Lua_Cheia," "Blank_Slate_Distiller's_Pak"

not sure if a periods are also a problem: "Pt._Bonita_Bohemian_Pils" "Mt._Baker_Maibock"

tmack8001 commented 3 years ago

Nah periods are or should be fine. Also the quotes in all honesty should be fine too, what would be problematic later (and cause invalid session files...) is a "#".

I'll look at escaping the "user input" in our django template which I thought was doing that by default, but apparently not.

tmack8001 commented 3 years ago

This is fixed now