Skip to content

Commit

Permalink
Escape more variables
Browse files Browse the repository at this point in the history
  • Loading branch information
wolffe committed Jun 12, 2024
1 parent ad372e4 commit 0a71e8d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion includes/builder/class-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function load_templates( $post_id ) {
var item_template = wp.template( 'fxb-item' );
<?php foreach ( $items_data as $item_id => $item ) { ?>
<?php if ( isset( $rows_data[ $item['row_id'] ] ) ) { ?>
$( '.fxb-row[data-id="<?php echo $item['row_id']; ?>"] .fxb-col[data-col_index="<?php echo $item['col_index']; ?>"] .fxb-col-content' ).append( item_template( <?php echo wp_json_encode( $item ); ?> ) );
$( '.fxb-row[data-id="<?php echo esc_attr( $item['row_id'] ); ?>"] .fxb-col[data-col_index="<?php echo esc_attr( $item['col_index'] ); ?>"] .fxb-col-content' ).append( item_template( <?php echo wp_json_encode( $item ); ?> ) );
<?php } ?>
<?php } // end foreach ?>
<?php } ?>
Expand Down
4 changes: 3 additions & 1 deletion includes/builder/class-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ public static function render_column( $args = array() ) {
);

$args = wp_parse_args( $args, $args_default );
extract( $args );

$title = $args['title'];
$index = $args['index'];

/* Var */
$field = "col_{$index}";
Expand Down
2 changes: 1 addition & 1 deletion includes/builder/class-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public function ajax_import_data() {
var item_template = wp.template( 'fxb-item' );
<?php foreach ( $items_data as $item_id => $item ) { ?>
<?php if ( isset( $rows_data[ $item['row_id'] ] ) ) { ?>
$( '.fxb-row[data-id="<?php echo $item['row_id']; ?>"] .fxb-col[data-col_index="<?php echo $item['col_index']; ?>"] .fxb-col-content' ).append( item_template( <?php echo wp_json_encode( $item ); ?> ) );
$( '.fxb-row[data-id="<?php echo esc_attr( $item['row_id'] ); ?>"] .fxb-col[data-col_index="<?php echo esc_attr( $item['col_index'] ); ?>"] .fxb-col-content' ).append( item_template( <?php echo wp_json_encode( $item ); ?> ) );
<?php } ?>
<?php } // end foreach ?>
<?php } ?>
Expand Down
2 changes: 1 addition & 1 deletion includes/settings/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function() {
?>
<p>
<label>
<input type="checkbox" value="<?php echo esc_attr( $post_type->name ); ?>" name="fx-builder_post_types[]" <?php checked( post_type_supports( $post_type->name, 'fx_builder' ) ); ?>> <?php echo $post_type->label; ?>
<input type="checkbox" value="<?php echo esc_attr( $post_type->name ); ?>" name="fx-builder_post_types[]" <?php checked( post_type_supports( esc_attr( $post_type->name ), 'fx_builder' ) ); ?>> <?php echo $post_type->label; ?>

Check failure on line 155 in includes/settings/class-settings.php

View workflow job for this annotation

GitHub Actions / CPCS

All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$post_type'.
</label>
</p>
<?php
Expand Down
4 changes: 2 additions & 2 deletions includes/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ function fxb_plugin_api_call( $def, $action, $args ) {
$request = wp_remote_post( $api_url, $request_string );

if ( is_wp_error( $request ) ) {
$res = new WP_Error( 'plugins_api_failed', __( 'An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>' ), $request->get_error_message() );
$res = new WP_Error( 'plugins_api_failed', __( 'An Unexpected HTTP Error occurred during the API request.</p> <p><a href="?" onclick="document.location.reload(); return false;">Try again</a>', 'fx-builder' ), $request->get_error_message() );
} else {
$res = unserialize( $request['body'] );

Check warning on line 63 in includes/updater.php

View workflow job for this annotation

GitHub Actions / CPCS

unserialize() found. Serialized data has known vulnerability problems with Object Injection. JSON is generally a better approach for serializing data. See https://www.owasp.org/index.php/PHP_Object_Injection

if ( $res === false ) {
$res = new WP_Error( 'plugins_api_failed', __( 'An unknown error occurred' ), $request['body'] );
$res = new WP_Error( 'plugins_api_failed', __( 'An unknown error occurred', 'fx-builder' ), $request['body'] );
}
}

Expand Down

0 comments on commit 0a71e8d

Please sign in to comment.