Question2Answer is a free and open source platform for Q&A sites, running on PHP/MySQL.
GNU General Public License v3.0
1.63k
stars
627
forks
source link
function qa_post_text() - Error : trim() expects parameter 1 to be string, array given #979
Open
q2apro opened 1 year ago
I had a hack bot on my site that tried to post an array instead of a string.
I am using for example:
$inemailhandle = qa_post_text('emailhandle');
Having an array, the base function
qa_post_text()
throws an error withtrim()
:Code line:
See https://github.com/q2a/question2answer/blob/4344721c138e7f6845a8129278c9d3374daee085/qa-include/qa-base.php#L1212
I assume we should always cast the
$_POST[$field]
to string?!Proposed Solution:
I see that the $array POST will then become the string
"Array"
and does not throw an error anymore.Can someone confirm this as a solution? Or is there a better way of handling this?
Thank you.