Skip to content

Commit

Permalink
Merge pull request #143 from wp-media/fixes
Browse files Browse the repository at this point in the history
Fixes for tabele sanitaize
  • Loading branch information
danielhuesken authored May 15, 2024
2 parents 2ce3116 + 1251cd9 commit b777590
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion inc/Database/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,10 @@ public function backup_table( $search = '', $replace = '', $table, $new_table_pr
$csv_head = str_getcsv( 'search,replace' );

foreach ( $csv_lines as $line ) {
$this->csv_data[] = array_combine( $csv_head, str_getcsv( $line ) );
$csv_line = str_getcsv( $line );
if ( count( $csv_line ) === 2 ) {
$this->csv_data[] = array_combine( $csv_head, $csv_line );
}
}
}

Expand Down
16 changes: 14 additions & 2 deletions inc/Page/SearchReplace.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,22 @@ private function get_csv_value() {
*/
private function selected_tables() {

$tables = [];
$tables = array();
$tables_db = $this->dbm->get_tables();

if ( ! empty( $_POST[ 'select_tables' ] ) ) {
$tables = filter_var( $_POST[ 'select_tables' ], FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY );
$tables = filter_var( $_POST[ 'select_tables' ], FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
}

if ( ! is_array( $tables ) ) {
return array();
}

$number_tables = count($tables);
for ( $i = 0; $i < $number_tables; $i++ ) {
if ( ! in_array( $tables[$i], $tables_db, true ) ) {
unset($tables[$i]);
}
}

return $tables;
Expand Down

0 comments on commit b777590

Please sign in to comment.