Jump to content

Sanitize user input: Difference between revisions

m
no edit summary
mNo edit summary
Line 2:
 
"Never trust user input." If the Super Mario Bros. 3 Wrong Warp or [[https://www.explainxkcd.com/wiki/index.php/Little_Bobby_Tables| Bobby Tables]] have taught programmers anything, it's that user input can be dangerous in unexpected ways.
 
In general, the task of preventing errors such as the above are best left to the built-in security features of the language rather than a filter of your own creation. This exercise is to test your ability to think about all the possible ways user input could break your program.
 
;Task:
Create a function that takes a list of 20 first and last names, and copies them to a record or struct. The list of names won't be provided here, because exploits like the Bobby Tables one are often language-specific. Try to show an example of a "Bobby Tables" style input in your list of names and how your function prevents it from being executed at runtime. For example, create a filter that prevents input that looks like your language's instructions from being entered, or escape it with the appropriate escape characters.
 
;Related tasks
1,489

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.