Skip to content

Commit 01166c5

Browse files
Merge pull request #912 from Codeinwp/bugfix/pro/339
Fix security vulnerability
2 parents 0a3269b + dfdd77f commit 01166c5

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

classes/Visualizer/Gutenberg/Block.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,12 @@ public function upload_csv_data( $data ) {
750750
return false;
751751
}
752752

753-
if ( $data['url'] && ! is_wp_error( $data['url'] ) && filter_var( $data['url'], FILTER_VALIDATE_URL ) ) {
754-
$source = new Visualizer_Source_Csv_Remote( $data['url'] );
753+
$remote_data = false;
754+
if ( isset( $data['url'] ) && function_exists( 'wp_http_validate_url' ) ) {
755+
$remote_data = wp_http_validate_url( $data['url'] );
756+
}
757+
if ( false !== $remote_data && ! is_wp_error( $remote_data ) ) {
758+
$source = new Visualizer_Source_Csv_Remote( $remote_data );
755759
if ( $source->fetch() ) {
756760
$temp = $source->getData();
757761
if ( is_string( $temp ) && is_array( unserialize( $temp ) ) ) {

classes/Visualizer/Module/Chart.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,10 +1111,15 @@ public function uploadData() {
11111111

11121112
$source = null;
11131113
$render = new Visualizer_Render_Page_Update();
1114-
if ( isset( $_POST['remote_data'] ) && filter_var( $_POST['remote_data'], FILTER_VALIDATE_URL ) ) {
1115-
$source = new Visualizer_Source_Csv_Remote( $_POST['remote_data'] );
1114+
1115+
$remote_data = false;
1116+
if ( isset( $_POST['remote_data'] ) && function_exists( 'wp_http_validate_url' ) ) {
1117+
$remote_data = wp_http_validate_url( $_POST['remote_data'] );
1118+
}
1119+
if ( false !== $remote_data ) {
1120+
$source = new Visualizer_Source_Csv_Remote( $remote_data );
11161121
if ( isset( $_POST['vz-import-time'] ) ) {
1117-
apply_filters( 'visualizer_pro_chart_schedule', $chart_id, $_POST['remote_data'], $_POST['vz-import-time'] );
1122+
apply_filters( 'visualizer_pro_chart_schedule', $chart_id, $remote_data, $_POST['vz-import-time'] );
11181123
}
11191124
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
11201125
} elseif ( isset( $_FILES['local_data'] ) && $_FILES['local_data']['error'] == 0 ) {

0 commit comments

Comments
 (0)