@@ -438,18 +438,30 @@ public function renderFlattrScript() {
438
438
* @access public
439
439
*/
440
440
public function uploadData () {
441
+ // if this is being called internally from pro and VISUALIZER_DO_NOT_DIE is set.
442
+ // otherwise, assume this is a normal web request.
443
+ $ can_die = ! ( defined ( 'VISUALIZER_DO_NOT_DIE ' ) && VISUALIZER_DO_NOT_DIE );
444
+
441
445
// validate nonce
442
- // do not use filter_input as it does not work for phpunit test cases, use filter_var instead
443
446
if ( ! isset ( $ _GET ['nonce ' ] ) || ! wp_verify_nonce ( $ _GET ['nonce ' ] ) ) {
447
+ if ( ! $ can_die ) {
448
+ return ;
449
+ }
444
450
status_header ( 403 );
445
451
exit ;
446
452
}
453
+
447
454
// check chart, if chart exists
455
+ // do not use filter_input as it does not work for phpunit test cases, use filter_var instead
448
456
$ chart_id = isset ( $ _GET ['chart ' ] ) ? filter_var ( $ _GET ['chart ' ], FILTER_VALIDATE_INT ) : '' ;
449
457
if ( ! $ chart_id || ! ( $ chart = get_post ( $ chart_id ) ) || $ chart ->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
458
+ if ( ! $ can_die ) {
459
+ return ;
460
+ }
450
461
status_header ( 400 );
451
462
exit ;
452
463
}
464
+
453
465
if ( ! isset ( $ _POST ['vz-import-time ' ] ) ) {
454
466
apply_filters ( 'visualizer_pro_remove_schedule ' , $ chart_id );
455
467
}
@@ -468,10 +480,8 @@ public function uploadData() {
468
480
}
469
481
} elseif ( isset ( $ _FILES ['local_data ' ] ) && $ _FILES ['local_data ' ]['error ' ] == 0 ) {
470
482
$ source = new Visualizer_Source_Csv ( $ _FILES ['local_data ' ]['tmp_name ' ] );
471
- // Added by Ash/Upwork
472
483
} elseif ( isset ( $ _POST ['chart_data ' ] ) && strlen ( $ _POST ['chart_data ' ] ) > 0 ) {
473
484
$ source = apply_filters ( 'visualizer_pro_handle_chart_data ' , $ _POST ['chart_data ' ], '' );
474
- // Added by Ash/Upwork
475
485
} else {
476
486
$ render ->message = esc_html__ ( 'CSV file with chart data was not uploaded. Please, try again. ' , 'visualizer ' );
477
487
}
@@ -489,9 +499,10 @@ public function uploadData() {
489
499
}
490
500
}
491
501
$ render ->render ();
492
- if ( ! ( defined ( ' VISUALIZER_DO_NOT_DIE ' ) && VISUALIZER_DO_NOT_DIE ) ) {
493
- defined ( ' WP_TESTS_DOMAIN ' ) ? wp_die () : exit () ;
502
+ if ( ! $ can_die ) {
503
+ return ;
494
504
}
505
+ defined ( 'WP_TESTS_DOMAIN ' ) ? wp_die () : exit ();
495
506
}
496
507
497
508
/**
0 commit comments