Plugin Directory

Changeset 3480946


Ignore:
Timestamp:
03/12/2026 08:44:20 AM (2 weeks ago)
Author:
bestwpdeveloper
Message:

Security fix: Added capability check and nonce verification - v1.3.2

Location:
cv-builder/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cv-builder/trunk/assets/public/js/qr-page-link.js

    r3456396 r3480946  
    1 
    21document.addEventListener('DOMContentLoaded', function () {
    32    if (typeof QRCode === 'undefined') {
     
    65    }
    76
    8     const qrCodeCanvas = document.getElementById('qr-code-canvas');
     7    const qrCanvases = document.querySelectorAll('canvas[data-url]');
     8    if (!qrCanvases.length) return;
    99
    10     if (!qrCodeCanvas) return;
     10    qrCanvases.forEach(function (qrCodeCanvas) {
     11        const {
     12            url,
     13            qrColor = '#000000',
     14            qrBgColor = '#ffffff',
     15            qrWidth = '150',
     16            qrMargin = '2',
     17            qrCorrectionLevel = 'L'
     18        } = qrCodeCanvas.dataset;
    1119
    12     const {
    13         url,
    14         qrColor = '#000000',
    15         qrBgColor = '#ffffff',
    16         qrWidth = '150',
    17         qrMargin = '2',
    18         qrCorrectionLevel = 'L'
    19     } = qrCodeCanvas.dataset;
     20        if (!url) return;
    2021
    21     if (url) {
    2222        const qrCodeOptions = {
    2323            color: {
     
    3333            if (error) console.error('QR Code generation failed:', error);
    3434        });
    35     }
     35    });
    3636});
  • cv-builder/trunk/assets/public/signature/signature.js

    r3472543 r3480946  
    22
    33function showContent(tabIndex) {
    4         const contents = document.querySelectorAll('.tab-content');
     4    const contents = document.querySelectorAll('.tab-content');
    55    contents.forEach((content) => content.classList.remove('active-content'));
    66    const tabs = document.querySelectorAll('.tab');
     
    178178        $.post(
    179179            wpSignatureCombo.ajax_url,
    180             { action: 'bwdcv_save_signature', image_data: imageData },
     180            {
     181                action: 'bwdcv_save_signature',
     182                security: wpSignatureCombo.nonce,
     183                image_data: imageData
     184            },
    181185            function (response) {
    182186                const result = JSON.parse(response);
     
    235239    }
    236240    textFontSignttre();
    237     })(jQuery);
     241})(jQuery);
    238242
    239243(function ($) {
  • cv-builder/trunk/bwdcv-boots.php

    r3474363 r3480946  
    147147            'bwdcv-qr-page-link',
    148148            $asset_url . 'js/qr-page-link.js',
    149             array( 'jquery', 'bwdcv-qr-code' ),
     149            array( 'bwdcv-qr-code' ),
    150150            BWDCV_VERSION,
    151151            true
  • cv-builder/trunk/includes/registration-form.php

    r3474363 r3480946  
    3636        // Signature
    3737        add_action( 'wp_ajax_bwdcv_save_signature', [ $this, 'wp_save_signature_image' ] );
    38         add_action( 'wp_ajax_nopriv_bwdcv_save_signature', [ $this, 'wp_save_signature_image' ] );
     38        // add_action( 'wp_ajax_nopriv_bwdcv_save_signature', [ $this, 'wp_save_signature_image' ] );
    3939        add_action( 'wp_enqueue_scripts', [ $this, 'wp_signature_enqueue_assets' ] );
    4040        // Loss pass form
     
    526526            wp_enqueue_script( 'wp-signature-combo-js', plugin_dir_url( __FILE__ ) . '../assets/public/signature/signature.js', [ 'jquery' ], null, true );
    527527            wp_enqueue_style( 'wp-signature-combo-css', plugin_dir_url( __FILE__ ) . '../assets/public/signature/signature.css' );
    528             wp_localize_script( 'wp-signature-combo-js', 'wpSignatureCombo', [ 'ajax_url' => admin_url( 'admin-ajax.php' ) ] );
     528            wp_localize_script( 'wp-signature-combo-js', 'wpSignatureCombo', [
     529                'ajax_url' => admin_url( 'admin-ajax.php' ),
     530                'nonce'    => wp_create_nonce( 'bwdcv_save_signature_nonce' ),
     531            ] );
    529532        }
    530533    }
    531534
    532535    public function wp_save_signature_image() {
    533         if ( isset( $_POST['image_data'] ) ) {
    534             $image_data    = $_POST['image_data'];
    535             $upload_dir    = wp_upload_dir();
    536             $file_name     = 'signature_' . time() . '.png';
    537             $file_path     = $upload_dir['path'] . '/' . $file_name;
    538             $decoded_image = base64_decode( str_replace( 'data:image/png;base64,', '', $image_data ) );
    539             file_put_contents( $file_path, $decoded_image );
    540             $attachment    = [
    541                 'guid'           => $upload_dir['url'] . '/' . $file_name,
    542                 'post_mime_type' => 'image/png',
    543                 'post_title'     => sanitize_file_name( $file_name ),
    544                 'post_content'   => '',
    545                 'post_status'    => 'inherit',
    546             ];
    547             $attachment_id = wp_insert_attachment( $attachment, $file_path );
    548             require_once( ABSPATH . 'wp-admin/includes/image.php' );
    549             $metadata = wp_generate_attachment_metadata( $attachment_id, $file_path );
    550             wp_update_attachment_metadata( $attachment_id, $metadata );
    551 
    552             echo wp_json_encode( [ 'success' => true, 'image_url' => $upload_dir['url'] . '/' . $file_name ] );
    553         }
     536
     537        check_ajax_referer( 'bwdcv_save_signature_nonce', 'security' );
     538
     539        if ( ! current_user_can( 'cv_editor' ) ) {
     540            wp_send_json_error( [ 'message' => 'Unauthorized' ], 403 );
     541            return;
     542        }
     543
     544        if ( ! isset( $_POST['image_data'] ) ) {
     545            wp_send_json_error( [ 'message' => 'No image data' ], 400 );
     546            return;
     547        }
     548
     549        $image_data = $_POST['image_data'];
     550        if ( ! str_starts_with( $image_data, 'data:image/png;base64,' ) ) {
     551            wp_send_json_error( [ 'message' => 'Invalid image format' ], 400 );
     552            return;
     553        }
     554        $base64_data   = str_replace( 'data:image/png;base64,', '', $image_data );
     555        $decoded_image = base64_decode( $base64_data, true );
     556
     557        if ( $decoded_image === false ) {
     558            wp_send_json_error( [ 'message' => 'Invalid base64 data' ], 400 );
     559            return;
     560        }
     561
     562        $upload_dir    = wp_upload_dir();
     563        $file_name     = 'signature_' . time() . '.png';
     564        $file_path     = $upload_dir['path'] . '/' . $file_name;
     565        file_put_contents( $file_path, $decoded_image );
     566        $attachment    = [
     567            'guid'           => $upload_dir['url'] . '/' . $file_name,
     568            'post_mime_type' => 'image/png',
     569            'post_title'     => sanitize_file_name( $file_name ),
     570            'post_content'   => '',
     571            'post_status'    => 'inherit',
     572        ];
     573        $attachment_id = wp_insert_attachment( $attachment, $file_path );
     574        require_once( ABSPATH . 'wp-admin/includes/image.php' );
     575        $metadata = wp_generate_attachment_metadata( $attachment_id, $file_path );
     576        wp_update_attachment_metadata( $attachment_id, $metadata );
     577
     578        echo wp_json_encode( [ 'success' => true, 'image_url' => $upload_dir['url'] . '/' . $file_name ] );
    554579        wp_die();
    555580    }
  • cv-builder/trunk/readme.txt

    r3474363 r3480946  
    66Tested up to: 6.9
    77Requires PHP: 7.0
    8 Stable tag: 1.3.1
     8Stable tag: 1.3.2
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    145145== Changelog ==
    146146
     147= 1.3.2 =
     148* Security fix: Added capability check and nonce verification
     149
    147150= 1.3.1 =
    148151* Fixed wp.org review issues
  • cv-builder/trunk/wp-cv-builder.php

    r3474363 r3480946  
    44 * Description: WP CV Builder with eye-catching style with 24+ preset design.
    55 * Plugin URI:  https://wpcvbuilder.com/
    6  * Version:     1.3.1
     6 * Version:     1.3.2
    77 * Author:      Best WP Developer
    88 * Author URI:  https://bestwpdeveloper.com/
     
    4141
    4242define( 'BWDCV_PLUGIN_NAME', plugin_basename( __DIR__ ) );
    43 define( "BWDCV_VERSION", '1.3.1' );
     43define( "BWDCV_VERSION", '1.3.2' );
    4444define( 'BWDCV_FILE', __FILE__ );
    4545define( 'BWDCV_DIR', __DIR__ );
Note: See TracChangeset for help on using the changeset viewer.