php - Protecting against user injection, running imagemagik from through command line -
i'm developing web app users supply utf8 text rendered onto images using imagemagik. i'm calling convert command through php's shell execute command.
i'm not versed on sanitizing user input (for injection) command line operations , have been having trouble finding resources exact situation.
the following article sounds don't have worry if user input entirely enclosed in quotes in bash command:
sanitize user input in bash security purposes
so question is, need worry user sanitation/escaping in following usage
<?php //get user supplied post data $user_input = $_post['text']; //call imagemagik via command line render image exec("convert -pointsize 50 -draw 'text 50,50 \"".$user_input."\" ' /source.png /output.png");
edit: since posting realized should running imagemagick installed library in php... guess, same question, using php object methods.
you can put user input text file , use @ filename prefix read it. way won't make command line ever.
$user_input = addslashes($user_input); file_put_contents("input.txt", "text 50,50 $user_input"); exec("convert -pointsize 50 -draw @input.txt /source.png /output.png");
Comments
Post a Comment