Cook-E-team / Cook-E

A mobile application that helps schedule cooking with multiple recipes
GNU General Public License v3.0
2 stars 1 forks source link

StorageParser does not work with arbitrary user input #22

Closed samcrow closed 8 years ago

samcrow commented 8 years ago

The current StorageParser implementation breaks when given some input.

I do not have a test case to reproduce this set of issues yet, but I can imagine some problematic situations:

Line breaks in user input

Imagine a Step with this description: "Do something\nDo something else"

When the Step is serialized with StorageParser.convertRecipeToString(Recipe), the output will contain a line break in the middle of a step description. When the application tries to parse the steps, the step will be split by the line break and parsing will fail.

Field keys in user input

Imagine a Step with "', mTime=" in its description. When the Step is serialized, the output will contain two occurrences of "', mTime=": One in the description, and one after the description. During parsing, the parser will find the first occurrence (in the description). That part of the description, and anything after it, will be lost. Even worse, the time parsing code will try to parse "', mTime=" as a number and will fail.

Resolution

The current serialization format has many issues. One way to resolve all of these would be to replace it with a standardized format that has thoroughly tested implementations, like JSON.

samcrow commented 8 years ago

Fixed.