Search code examples
phphtmlfgets

Why can't I submit text that contains the function fgets()?


I use my website to code (and progress in my programming projects) online, during school, and send the code to my email address to continue working on it at home.

The text can be inside a <textarea> or an <input> field (with name="Code" id="Code").
Either way, I'm unable to submit text that contains the C/C++ function fgets():

TODO: Include a more stable function to get user input,
      such as fgets(input, 20, stdin);

I have no idea why submitting the text: fgets(input, 20, stdin) would be a problem, and why any text inside a <textarea> or <input> would be a problem since it's all just plain text, and not actual code.

When I click submit, while text in my <textarea> contains fgets(), nothing happens (instead of giving me Invalid input message or Email Sent message), and my text isn't being sent.


Solution

  • It may be that something on your server sees this as an attempt to hack the site.

    A quick Googling shows that mod_security (a fairly common Apache module that attempts to prevent things like SQL injection and other exploits) may be blocking POST parameters that include fgets() calls. http://forums.modx.com/thread?thread=9677