yehster wrote on Wednesday, January 11, 2012:
Brady,
I have to admit that I wasn’t fully aware of the magic quotes issue before I committed. I thought it was indeed a trivial change.
However, is the magic quotes concept really relevant for $issue? It’s not valid for single quotes, double quotes or backslashes to appear in that variable in the first place since it needs to represent an integer value as a key into the list table.
In other words, $_REQUEST shouldn’t contain ",’ or \ in the first place, so if it did that likely means someone is messing with the get request manually (at their own peril…)
(also for the long sql-queries with multiple variables, rather than use binding, can use the add_escape_custom() function from library/formdata.inc.php script instead)
You’re saying that for the below current code, all of the values should be wrapped with add_escape_custom(), (easier than re-writing with binding, whew)!
if ($issue) {
$query = "UPDATE lists SET " .
"type = '" . $text_type . "', " .
"title = '" . $_POST['form_title'] . "', " .
"comments = '" . $_POST['form_comments'] . "', " .
"begdate = " . QuotedOrNull($form_begin) . ", " .
"enddate = " . QuotedOrNull($form_end) . ", " .
"returndate = " . QuotedOrNull($form_return) . ", " .
"diagnosis = '" . $_POST['form_diagnosis'] . "', " .
"occurrence = '" . $_POST['form_occur'] . "', " .
"classification = '" . $_POST['form_classification'] . "', " .
"reinjury_id = '" . $_POST['form_reinjury_id'] . "', " .
"referredby = '" . $_POST['form_referredby'] . "', " .
"injury_grade = '" . $_POST['form_injury_grade'] . "', " .
"injury_part = '" . $form_injury_part . "', " .
"injury_type = '" . $form_injury_type . "', " .
"outcome = '" . $_POST['form_outcome'] . "', " .
"destination = '" . $_POST['form_destination'] . "', " .
"reaction ='" . $_POST['form_reaction'] . "', " .
"erx_uploaded = '0' " .
"WHERE id = '$issue'";
sqlStatement($query);
Anyway, I’ll keep this on my queue so we can talk about the security model for my benefit and for any other interested parties. I will commit to a personal branch and solicit feedback next time before updating sourceforge.