Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape data before using them in SQL #289

Merged
merged 1 commit into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion fields/field.memberactivation.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation=false
// Filter has + in it.
if($andOperation) {
foreach($data as $key => $bit){
$bit = Symphony::Database()->cleanValue($bit);
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id$key` ON (`e`.`id` = `t$field_id$key`.entry_id) ";
$where .= " AND `t$field_id$key`.activated = '$bit' ";
}
Expand All @@ -492,7 +493,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation=false
if(!is_array($data)) {
$data = array($data);
}

$data = array_map(array(Symphony::Database(), 'cleanValue'), $data);
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id` ON (`e`.`id` = `t$field_id`.entry_id) ";
$where .= " AND `t$field_id`.activated IN ('".implode("', '", $data)."') ";
}
Expand Down
3 changes: 2 additions & 1 deletion fields/field.memberemail.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation=false
// Filter has + in it.
else if($andOperation) {
foreach($data as $key => $bit){
$bit = Symphony::Database()->cleanValue($bit);
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id$key` ON (`e`.`id` = `t$field_id$key`.entry_id) ";
$where .= " AND (
`t$field_id$key`.value = '$bit'
Expand All @@ -253,7 +254,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation=false
if(!is_array($data)) {
$data = array($data);
}

$data = array_map(array(Symphony::Database(), 'cleanValue'), $data);
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id` ON (`e`.`id` = `t$field_id`.entry_id) ";
$where .= " AND (
`t$field_id`.value IN ('".implode("', '", $data)."')
Expand Down
2 changes: 2 additions & 0 deletions fields/field.memberpassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation=false
foreach($data as $key => $value) {
$this->_key++;
$value = $this->encodePassword($value);
$value = Symphony::Database()->cleanValue($value);
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id$key` ON (`e`.`id` = `t$field_id$key`.entry_id) ";
$where .= " AND `t$field_id$key`.password = '$value' ";
}
Expand All @@ -648,6 +649,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation=false
$value = $this->encodePassword($value);
}

$data = array_map(array(Symphony::Database(), 'cleanValue'), $data);
$data = implode("', '", $data);
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id` ON (`e`.`id` = `t$field_id`.entry_id) ";
$where .= " AND `t$field_id`.password IN ('{$data}') ";
Expand Down
2 changes: 2 additions & 0 deletions fields/field.memberrole.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,15 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = fal

if($andOperation) {
foreach($data as $key => $bit){
$bit = Symphony::Database()->cleanValue($bit);
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id$key` ON (`e`.`id` = `t$field_id$key`.entry_id) ";
$joins .= " LEFT JOIN `tbl_members_roles` AS `tg$field_id$key` ON (`t$field_id$key`.`role_id` = `tg$field_id$key`.id) ";
$where .= " AND (`t$field_id$key`.role_id = '$bit' OR (`tg$field_id$key`.name = '$bit' OR `tg$field_id$key`.handle = '$bit')) ";
}
}
else {
$data = !is_array($data) ? array($data) : $data;
$data = array_map(array(Symphony::Database(), 'cleanValue'), $data);
$value = implode("', '", $data);

$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id` ON (`e`.`id` = `t$field_id`.entry_id) ";
Expand Down
3 changes: 2 additions & 1 deletion lib/class.identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation=false
// Filter has + in it.
else if($andOperation) {
foreach($data as $key => $bit){
$bit = Symphony::Database()->cleanValue($bit);
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id$key` ON (`e`.`id` = `t$field_id$key`.entry_id) ";
$where .= " AND (
`t$field_id$key`.value = '$bit'
Expand All @@ -148,7 +149,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation=false
if(!is_array($data)) {
$data = array($data);
}

$data = array_map(array(Symphony::Database(), 'cleanValue'), $data);
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t$field_id` ON (`e`.`id` = `t$field_id`.entry_id) ";
$where .= " AND (
`t$field_id`.value IN ('".implode("', '", $data)."')
Expand Down