Why can't I send text containing the fgets () function?

I use my site to encode (and progress in my programming projects) on the Internet, while studying and sending the code to my email address to continue working on it at home.

The text can be inside the <textarea> or <input> field (using name="Code" id="Code" ).
In any case, I cannot send text containing the C / C ++ fgets() function:

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

I have no idea why to send text: fgets(input, 20, stdin) will be a problem, and why any text inside <textarea> or <input> will be a problem, because all this is just text, not the actual code.

When I click the Submit button and the text in <textarea> contains fgets() , nothing happens (instead of the Invalid input message or Email Sent message), and my text is not sent.

+4
source share
2 answers

Perhaps something on your server sees this as an attempt to hack a site.

A quick Google search reveals that mod_security (a fairly common Apache module that tries to prevent things like SQL injection and other exploits) can block POST options that include fgets() calls. http://forums.modx.com/thread?thread=9677

+7
source

You should not convert the arguments to a single line yourself (or, if so, use the javascript alternative for phps urlencode() ),

jQuery supports [1] , [2] data as an anonymous object

Data to send to the server. It is converted to a query string, if not already a string. It is added to the URL for GET requests. See processData to prevent this automatic processing. The object must be key / value pairs. If the value is an array, jQuery serializes multiple values ​​with the same key based on the value of the traditional setting (described below).

so you can use:

 data: { 'Name': name, 'Code': code, ... } 

and it should work, and more importantly for proper encoding (shielding). If this does not help (the problem is not the incorrect "raw data"), try the ceejayoz solution .

0
source

Source: https://habr.com/ru/post/1439575/


All Articles