GNOME Bugzilla – Bug 779621
Restrict the input for "preparation time" and "cooking time"
Last modified: 2017-03-28 20:32:56 UTC
Created attachment 347271 [details] Both the fields accepting any random string Both the fields accept any random strings.
My take on this is that we should do enough validation to prevent issues like crashes, or inability to load the database the next time. Things we can consider: - disallow newlines - limit the length of the input
(In reply to Matthias Clasen from comment #1) > My take on this is that we should do enough validation to prevent issues > like crashes, or inability to load the database the next time. Things we can > consider: > > - disallow newlines > - limit the length of the input Ideally a user should not put in a string like that but disallowing newlines and limiting input length still wont stop users to type "abc" as the preparation time and cooking time. Is removal the editable feature of combobox too much of a restriction? Because it still gives a broad idea of around how long does the recipe takes.
no, that may be just fine. Lets see if I can Jakub to chime in here.
Whatever you come up with to restrict the format, I favor trying to convert the format to alerting a format being incorrect. I don't consider allowing "abc" for time as much of a deal to disallowing "Roughly 2 hours". The only somewhat real use case for being strict with preparation time format is search. But perhaps searching for recipes that will "take less than 20 minutes to make, because I need to leave for a plane in an hour" is a bit of a stretch.
I guess that makes sense - we don't need this field to be machine-readable, so any restrictions we apply should be targeted at making sure that we get a string that doesn't break the database and doesn't break the layout of the details page or the print output. A value like 'abc' might not make for a useful preparation time, but it doesn't do any actual harm...
(In reply to Matthias Clasen from comment #5) > I guess that makes sense - we don't need this field to be machine-readable, > so any restrictions we apply should be targeted at making sure that we get a > string that doesn't break the database and doesn't break the layout of the > details page or the print output. A value like 'abc' might not make for a > useful preparation time, but it doesn't do any actual harm... Hence, - disallow newlines - limit the length of the input. What would be the limit of length?
as much as can fit on the details page, looks like 30 characters is the answer...
Created attachment 347359 [details] 30 characters
Created attachment 348175 [details] [review] Limit preptime_combo and cook_time_combo text to 30 chars
Review of attachment 348175 [details] [review]: Works fine in my testing. Lets go with it.
We should put this patch on both the master and the recipes-1.0 branch.
and we should probably do the same for the other entries on the edit page
Created attachment 348633 [details] [review] Restricts all the entries on edit-page to 30 chars
Review of attachment 348633 [details] [review]: Patch itself looks great; can you put something in the commit message body when you push this ? Like Allowing arbitrarily long strings for these fields is not necessary and breaks the layout of the details page.
Created attachment 348899 [details] [review] Restricts all the entries on edit-page to 30 chars