I'm not sure if this question is within the scope of security.stackexchange or it would be more suitable on stackoverflow. Let me know if needed.
I'm wetting my feet in PHP, and I've put together a very simple program that (using JavaScript) receives as user input a .txt file, sanitizes it to remove all punctuation, then sends the string (via ajax post) to a php script that does some very simple calculations (e.g. the length of the string, how many times a certain substring appears, etc), then returns the results to the JS script for display on the web page.
My question is:
Is there anything risky about this process if we assumed a malicious user? Is there anything they could upload and send to the php script that would compromise the server? My instinct is to say no, since the PHP script is extremely simple and only performs string calculations (not to mention that all punctuation is removed from the input file), but since I'm really inexperienced with PHP, I thought to ask and make sure before I share it with anyone.
If any further information is required, let me know.
$.post("file.php", { variable: string }, function (data) {console.log(data)}
to send the string, and on file.php I receive it with$string= $_POST['variable'];
. Could you elaborate on how this could be interpreted as valid code? I mean, if file.php, as I said, only performs simple string operations, is it still possible that code be executed?