Plugin Directory

Changeset 3835028


Ignore:
Timestamp:
11/30/2026 12:04:28 PM (less than one hour ago)
Author:
pikocode
Message:

Version 1.4.9.0: security fixes for CVE-2026-119231 + fixes on babylon JS and mailing issues found while testing

Location:
3d-print-pricing-calculator
Files:
46 added
9 edited

Legend:

Unmodified
Added
Removed
  • 3d-print-pricing-calculator/trunk/3d-print-pricing-calculator.php

    r3632805 r3835028  
    55 * Author: odysse.io
    66 * Author URI: https://odysse.io/
    7  * Version: 1.4.8.9
     7 * Version: 1.4.9.0
    88 * Text Domain: 3d-print-pricing-calculator
    99 * License: GPL-3.0
    … …  
    2828
    2929// Define plugin version and constants
    30 define('PPC3D_VERSION', '1.4.8.9');
     30define('PPC3D_VERSION', '1.4.9.0');
    3131define('PPC3D_PLUGIN_PATH', plugin_dir_path(__FILE__));
    3232define('PPC3D_PLUGIN_URL', plugin_dir_url(__FILE__));
    … …  
    6262function ppc3d_stl_parser_enqueue_scripts()
    6363{
    64     wp_enqueue_script('babylon', 'https://cdn.babylonjs.com/babylon.js', array(), '7.25.1', true);
    65     wp_enqueue_script('babylon-loader', 'https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js', array(), '7.25.1', true);
     64    wp_enqueue_script('babylon', 'https://cdn.babylonjs.com/v7.25.1/babylon.js', array(), '7.25.1', true);
     65    wp_enqueue_script('babylon-loader', 'https://cdn.babylonjs.com/v7.25.1/loaders/babylonjs.loaders.min.js', array(), '7.25.1', true);
    6666
    6767    if (!is_admin()) {
    … …  
    111111function ppc3d_enqueue_custom_admin_styles()
    112112{
     113    if (! current_user_can('manage_options')) {
     114        return;
     115    }
     116
    113117    // Enqueue main admin styles
    114118    $style_path_admin = plugin_dir_path(__FILE__) . 'css/admin-style.css';
    … …  
    124128    wp_localize_script('stl-parser-admin-script', 'ppc3d_stl_parser_admin', array(
    125129        'ajaxurl' => admin_url('admin-ajax.php'),
    126         'nonce' => wp_create_nonce('ppc3d_upload_stl_nonce'),
     130        'nonce' => wp_create_nonce('ppc3d_admin_nonce'),
    127131    ));
    128132
    … …  
    156160add_action('wp_ajax_ppc3d_upload_stl_file', 'ppc3d_upload_stl_file');
    157161add_action('wp_ajax_nopriv_ppc3d_upload_stl_file', 'ppc3d_upload_stl_file');
    158 add_action('wp_ajax_ppc3d_show_stl_file', 'ppc3d_show_stl_file');
    159 add_action('wp_ajax_nopriv_ppc3d_show_stl_file', 'ppc3d_show_stl_file');
    160162add_action('wp_ajax_ppc3d_send_purchase_emails', 'ppc3d_send_purchase_emails_callback');
    161163add_action('wp_ajax_ppc3d_complete_onboarding', 'ppc3d_complete_onboarding_callback');
    … …  
    194196    if (! check_ajax_referer('ppc3d_upload_stl_nonce', 'nonce', false)) {
    195197        wp_send_json_error('Nonce verification failed.');
    196         wp_die();
    197198    }
    198199
    … …  
    201202
    202203    // Verify file upload exists
    203     if (!isset($_FILES[$file_key])) {
     204    if (! isset($_FILES[$file_key]) || ! is_array($_FILES[$file_key]) || ! isset($_FILES[$file_key]['name'], $_FILES[$file_key]['tmp_name'])) {
    204205        wp_send_json_error('No file uploaded.');
    205         wp_die();
    206     }
    207 
    208     // Use wp_handle_upload for sanitizing and handling the file upload
    209     $upload_overrides = ['test_form' => false]; // Disable test for POST form field
    210     $upload_dir = wp_upload_dir();
    211     $upload_path = trailingslashit($upload_dir['path']); // Directory path for uploads
    212 
    213     // Get original file name and sanitize it
    214     $file_name = sanitize_file_name($_FILES[$file_key]['name']);
    215     $file_path = $upload_path . $file_name;
    216 
    217     // Check if the file already exists and delete it
    218     if (file_exists($file_path)) {
    219         unlink($file_path); // Deletes the existing file
    220     }
    221 
    222     // Upload the new file
     206    }
     207
     208    if (! is_string($_FILES[$file_key]['name']) || ! is_string($_FILES[$file_key]['tmp_name'])) {
     209        wp_send_json_error('Invalid upload.');
     210    }
     211
     212    $original_name = sanitize_file_name(wp_unslash($_FILES[$file_key]['name']));
     213    if ('stl' !== strtolower(pathinfo($original_name, PATHINFO_EXTENSION))) {
     214        wp_send_json_error('Invalid file type. Please upload an STL file.');
     215    }
     216
     217    $tmp_size = isset($_FILES[$file_key]['size']) ? (int) $_FILES[$file_key]['size'] : 0;
     218    if ($tmp_size < 84) {
     219        wp_send_json_error('Invalid STL file.');
     220    }
     221
     222    $upload_overrides = array(
     223        'test_form' => false,
     224        'mimes'     => array('stl' => 'application/sla'),
     225    );
    223226    $uploaded_file = wp_handle_upload($_FILES[$file_key], $upload_overrides);
    224227
    225     // Check if the file was uploaded successfully
    226228    if (isset($uploaded_file['error'])) {
    227229        wp_send_json_error('File upload error: ' . $uploaded_file['error']);
    228         wp_die();
    229     }
    230 
    231     // Verify the file extension is STL
    232     $file_extension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
    233     if ($file_extension !== 'stl') {
    234         // Delete the file if it's not an STL
     230    }
     231
     232    $stored_name = wp_basename($uploaded_file['file']);
     233    if ('stl' !== strtolower(pathinfo($stored_name, PATHINFO_EXTENSION))) {
    235234        wp_delete_file($uploaded_file['file']);
    236235        wp_send_json_error('Invalid file type. Please upload an STL file.');
    237         wp_die();
    238     }
    239 
    240     // Return the file details
    241     return [
    242         'file_name' => $file_name,
    243         'root_url' => trailingslashit($upload_dir['url']),
     236    }
     237
     238    $upload_dir = wp_upload_dir();
     239
     240    return array(
     241        'file_name'        => $stored_name,
     242        'root_url'         => trailingslashit($upload_dir['url']),
    244243        'site_upload_path' => esc_url_raw($uploaded_file['url']),
    245         'upload_path' => $uploaded_file['file'],
    246     ];
     244        'upload_path'      => $uploaded_file['file'],
     245    );
    247246}
    248247
    … …  
    288287        $parsed_data = ppc3d_parse_stl_file($file_data['upload_path'], $unit, $scale);
    289288    } catch (Exception $e) {
    290         error_log('STL parse error: ' . $e->getMessage());
    291289        wp_send_json_error('Unable to parse STL file.');
    292290        return;
    … …  
    373371    // Generate a unique transient key using wp_generate_uuid4
    374372    $transient_key = sanitize_key('ppc3d_data_' . wp_generate_uuid4());
    375     set_transient('ppc3d_transient_key', $transient_key, DAY_IN_SECONDS);
    376373
    377374    $printing_technology_name = isset($_POST['printing_technology_name']) ? sanitize_text_field(wp_unslash($_POST['printing_technology_name'])) : ''; // Sanitize as string
    … …  
    401398    // Make sure we have the expected structure
    402399    if (!isset($data['data']['formated_data']) || !is_array($data['data']['formated_data'])) {
    403         error_log('Expected formated_data structure not found, creating it');
    404400       
    405401        // Initialize the structure if it doesn't exist
    … …  
    451447        }
    452448    } else {
    453         error_log('Found expected formated_data structure');
    454449    }
    455450   
    456451    // Ensure all values have proper formatting
    457452    if (isset($data['data']['formated_data'])) {
    458         // Allow only valid currency symbols in the price string
    459         $currency_symbol = get_option('ppc3d_currency_symbol', '$');
    460         $currency_position = get_option('ppc3d_currency_position', 'before');
    461         $allowed_symbols = preg_quote($currency_symbol, '/') . '$£€¥₹₩';
    462 
    463453        // Make sure price has currency symbol
    464         if (isset($data['data']['formated_data']['price']) && !preg_match('/[^0-9.,\s' . $allowed_symbols . ']/u', $data['data']['formated_data']['price'])) {
     454        if (isset($data['data']['formated_data']['price']) && !preg_match('/[^0-9.,\s]/', $data['data']['formated_data']['price'])) {
     455            $currency_symbol = get_option('ppc3d_currency_symbol', '$');
     456            $currency_position = get_option('ppc3d_currency_position', 'before');
     457           
    465458            $price_value = floatval(preg_replace('/[^0-9.]/', '', $data['data']['formated_data']['price']));
    466 
     459           
    467460            if ($currency_position === 'before') {
    468461                $data['data']['formated_data']['price'] = $currency_symbol . number_format($price_value, 2);
    … …  
    611604function ppc3d_get_transient_data($request) {
    612605    // Get the transient key from the request
    613     $transient_key = sanitize_text_field($request->get_param('transient_key'));
    614    
    615     if (empty($transient_key)) {
     606    $transient_key = sanitize_key($request->get_param('transient_key'));
     607
     608    if (empty($transient_key) || 0 !== strpos($transient_key, 'ppc3d_data_')) {
    616609        return new WP_REST_Response(array(
    617610            'success' => false,
    … …  
    619612        ), 400);
    620613    }
    621    
     614
    622615    // Get the transient data
    623616    $transient_data = get_transient($transient_key);
    624    
     617
    625618    if (false === $transient_data) {
    626619        return new WP_REST_Response(array(
    … …  
    629622        ), 404);
    630623    }
    631    
    632     // Log the transient data for debugging
    633     error_log('Transient key: ' . $transient_key);
    634     error_log('Formatted data: ' . print_r($transient_data, true));
    635    
     624
    636625    return new WP_REST_Response(array(
    637626        'success' => true,
    … …  
    647636        $customerEmail = sanitize_email($request->get_param('email'));
    648637        $shippingAddress = sanitize_text_field($request->get_param('shippingAddress'));
    649         $transient_key = sanitize_text_field($request->get_param('transient_key_field'));
     638        $transient_key = sanitize_key($request->get_param('transient_key_field'));
    650639        $admin_email = get_option('admin_email'); // WordPress admin email
     640
     641        if (! is_email($customerEmail)) {
     642            return new WP_REST_Response(array(
     643                'success' => false,
     644                'data' => array('message' => 'A valid email address is required.')
     645            ), 400);
     646        }
     647
     648        if (empty($transient_key) || 0 !== strpos($transient_key, 'ppc3d_data_')) {
     649            return new WP_REST_Response(array(
     650                'success' => false,
     651                'data' => array('message' => 'Invalid or expired quote. Please upload your file again.')
     652            ), 400);
     653        }
    651654
    652655        // Retrieve formatted data from the transient using the transient key
    653656        $formatted_data = get_transient($transient_key);
    654        
    655         // Debug log to check what's in the transient
    656         error_log('Transient key: ' . $transient_key);
    657         error_log('Formatted data: ' . print_r($formatted_data, true));
     657
     658        if (false === $formatted_data) {
     659            return new WP_REST_Response(array(
     660                'success' => false,
     661                'data' => array('message' => 'Invalid or expired quote. Please upload your file again.')
     662            ), 400);
     663        }
     664
     665        $submitted_flag = 'ppc3d_sub_' . md5($transient_key);
     666        if (get_transient($submitted_flag)) {
     667            return new WP_REST_Response(array(
     668                'success' => false,
     669                'data' => array('message' => 'This quote has already been submitted.')
     670            ), 429);
     671        }
    658672
    659673        // Generate dynamic order number using timestamp and a random number
    660         $orderNumber = 'ORD-' . time() . '-' . rand(1000, 9999);
     674        $orderNumber = 'ORD-' . time() . '-' . wp_rand(1000, 9999);
    661675
    662676        // Customer email subject
    … …  
    752766        // Fallback to direct access if formated_data is not available
    753767        elseif (is_array($formatted_data)) {
    754             error_log('Trying alternative data structure access - direct access');
    755768           
    756769            // Try to access fields directly
    … …  
    795808        if ($orderDetails === "<ul>") {
    796809            $orderDetails .= "<li><em>No calculation data available</em></li>";
    797             error_log('No calculation data found in transient: ' . print_r($formatted_data, true));
    798810        }
    799811       
    … …  
    832844        // Try to access options directly from the formatted_data
    833845        elseif (is_array($formatted_data)) {
    834             error_log('Trying alternative data structure for options - direct access');
    835846           
    836847            if (isset($formatted_data['printing_technology_name'])) {
    … …  
    862873        if ($optionsDetails === "<ul>") {
    863874            $optionsDetails .= "<li><em>No options data available</em></li>";
    864             error_log('No options data found in transient');
    865875        }
    866876       
    … …  
    899909        // Handle email sending status and response
    900910        if ($email_sent_customer && $email_sent_admin) {
     911            set_transient($submitted_flag, 1, DAY_IN_SECONDS);
    901912            return new WP_REST_Response(array(
    902913                'success' => true,
    … …  
    918929            'data' => array(
    919930                'message' => 'An unexpected error occurred.',
    920                 'error' => $e->getMessage()
     931                'error' => 'Please try again later.'
    921932            )
    922933        ), 500);
  • 3d-print-pricing-calculator/trunk/includes/admin-email-templates.php

    r3572835 r3835028  
    1212{
    1313  // Save form
    14   if (isset($_POST['ppc3d_email_template_nonce']) && wp_verify_nonce($_POST['ppc3d_email_template_nonce'], 'ppc3d_save_email_template')) {
    15     $template_content = wp_unslash($_POST['email_template_content']);
     14  if (! current_user_can('manage_options')) {
     15    return;
     16  }
     17
     18  if (isset($_POST['ppc3d_email_template_nonce'], $_POST['email_template_content']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['ppc3d_email_template_nonce'])), 'ppc3d_save_email_template')) {
     19    $template_content = wp_kses_post(wp_unslash($_POST['email_template_content']));
    1620    $use_default = isset($_POST['use_default_template']) ? 'yes' : 'no';
    17 
    18     remove_filter('pre_update_option_ppc3d_email_template', 'wp_filter_kses');
    19     remove_filter('pre_update_option_ppc3d_email_template', 'sanitize_text_field');
    2021
    2122    update_option('ppc3d_email_template', $template_content);
  • 3d-print-pricing-calculator/trunk/includes/admin-file-manager.php

    r3572835 r3835028  
    1313    // Process file deletion if requested
    1414    if (isset($_POST['action']) && $_POST['action'] === 'delete_file' && isset($_POST['file_path']) && isset($_POST['nonce'])) {
    15         if (wp_verify_nonce($_POST['nonce'], 'ppc3d_delete_file_nonce')) {
     15        if (wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_delete_file_nonce')) {
    1616            $file_path = sanitize_text_field(wp_unslash($_POST['file_path']));
    1717            $upload_dir = wp_upload_dir();
    18             $base_dir = $upload_dir['basedir'];
    19            
    20             // Ensure the file is within the uploads directory
    21             if (strpos($file_path, $base_dir) === 0 && file_exists($file_path)) {
     18            $base_dir = wp_normalize_path(realpath($upload_dir['basedir']));
     19            $real_path = realpath($file_path);
     20            $real_path = $real_path ? wp_normalize_path($real_path) : '';
     21
     22            $is_tracked = false;
     23            foreach ((array) get_option('ppc3d_uploaded_files', array()) as $tracked) {
     24                if (isset($tracked['file_path']) && $tracked['file_path'] === $file_path) {
     25                    $is_tracked = true;
     26                    break;
     27                }
     28            }
     29
     30            if (
     31                $is_tracked
     32                && $base_dir
     33                && $real_path
     34                && 0 === strpos($real_path, trailingslashit($base_dir))
     35                && 'stl' === strtolower(pathinfo($real_path, PATHINFO_EXTENSION))
     36                && is_file($real_path)
     37            ) {
    2238                // Delete the physical file
    23                 if (unlink($file_path)) {
     39                if (wp_delete_file($real_path) || ! file_exists($real_path)) {
    2440                    // Remove the file from metadata
    2541                    $uploaded_files = get_option('ppc3d_uploaded_files', array());
  • 3d-print-pricing-calculator/trunk/includes/admin-settings.php

    r3572835 r3835028  
    22
    33define('ppc3d_file', __FILE__); // Define the plugin file constant
     4
     5function ppc3d_verify_admin_ajax()
     6{
     7  $nonce = isset($_POST['nonce']) ? sanitize_text_field(wp_unslash($_POST['nonce'])) : '';
     8
     9  if (! $nonce || ! wp_verify_nonce($nonce, 'ppc3d_admin_nonce')) {
     10    wp_send_json_error('Security check failed. Please refresh the page and try again.', 403);
     11  }
     12
     13  if (! current_user_can('manage_options')) {
     14    wp_send_json_error('Insufficient permissions.', 403);
     15  }
     16}
    417
    518// AJAX handler for saving currency settings
    … …  
    233246  wp_localize_script('ppc3d-admin-script', 'ppc3d_ajax', array(
    234247    'ajax_url' => admin_url('admin-ajax.php'),
    235     'nonce' => wp_create_nonce('ppc3d_upload_stl_nonce')
     248    'nonce' => wp_create_nonce('ppc3d_admin_nonce')
    236249  ));
    237250
    … …  
    11421155function ppc3d_add_printing_technology_option_callback()
    11431156{
    1144   // Verify nonce
    1145   if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1146     // Nonce verification failed
    1147     wp_die('Nonce verification failed. Please refresh the page and try again.');
    1148   }
     1157  ppc3d_verify_admin_ajax();
    11491158
    11501159  // Ensure the required fields are set
    … …  
    11891198function ppc3d_edit_printing_technology_option_callback()
    11901199{
    1191   // Verify nonce
    1192   if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1193     wp_send_json_error('Nonce verification failed.');
    1194     wp_die();
    1195   }
     1200  ppc3d_verify_admin_ajax();
    11961201
    11971202  // Validate required fields
    … …  
    12641269function ppc3d_delete_printing_technology_option_callback()
    12651270{
    1266   // Verify nonce
    1267   if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1268     // Nonce verification failed
    1269     wp_die('Nonce verification failed. Please refresh the page and try again.');
    1270   }
     1271  ppc3d_verify_admin_ajax();
    12711272  if (isset($_POST['optionName'])) {
    12721273    $optionName = sanitize_text_field(wp_unslash($_POST['optionName']));
    … …  
    13261327function ppc3d_add_material_option_callback()
    13271328{
    1328   // Verify nonce
    1329   if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1330     // Nonce verification failed
    1331     wp_die('Nonce verification failed. Please refresh the page and try again.');
    1332   }
     1329  ppc3d_verify_admin_ajax();
    13331330  // Ensure the required fields are set
    13341331  if (isset($_POST['material'], $_POST['material_value'], $_POST['material_description'])) {
    … …  
    13711368function ppc3d_edit_material_option_callback()
    13721369{
    1373   // Verify nonce
    1374   if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1375     wp_send_json_error('Nonce verification failed.');
    1376     wp_die();
    1377   }
     1370  ppc3d_verify_admin_ajax();
    13781371
    13791372  // Validate required fields
    … …  
    14471440function ppc3d_delete_material_option_callback()
    14481441{
    1449   // Verify nonce
    1450   if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1451     // Nonce verification failed
    1452     wp_die('Nonce verification failed. Please refresh the page and try again.');
    1453   }
     1442  ppc3d_verify_admin_ajax();
    14541443  if (isset($_POST['optionName'])) {
    14551444    $optionName = sanitize_text_field(wp_unslash($_POST['optionName']));
    … …  
    15221511function ppc3d_add_quality_option_callback()
    15231512{
    1524   // Verify nonce
    1525   if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1526     wp_send_json_error('Nonce verification failed.');
    1527     wp_die();
    1528   }
     1513  ppc3d_verify_admin_ajax();
    15291514
    15301515  // Check if required fields are set
    … …  
    15681553function ppc3d_edit_quality_option_callback()
    15691554{
    1570   // Verify nonce
    1571   if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1572     wp_send_json_error('Nonce verification failed.');
    1573     wp_die();
    1574   }
     1555  ppc3d_verify_admin_ajax();
    15751556
    15761557  // Validate required fields
    … …  
    16431624function ppc3d_delete_quality_option_callback()
    16441625{
    1645   // Verify nonce
    1646   if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1647     // Nonce verification failed
    1648     wp_die('Nonce verification failed. Please refresh the page and try again.');
    1649   }
     1626  ppc3d_verify_admin_ajax();
    16501627  if (isset($_POST['optionName'])) {
    16511628    $optionName = sanitize_text_field(wp_unslash($_POST['optionName']));
    … …  
    16991676function ppc3d_add_infill_option_callback()
    17001677{
    1701   // Verify nonce
    1702   if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1703     // Nonce verification failed
    1704     wp_die('Nonce verification failed. Please refresh the page and try again.');
    1705   }
     1678  ppc3d_verify_admin_ajax();
    17061679  // Check if required fields are set
    17071680  if (!isset($_POST['infill'], $_POST['infill_value'], $_POST['infill_description'])) {
    … …  
    17471720function ppc3d_edit_infill_option_callback()
    17481721{
    1749   // Verify nonce
    1750   if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1751     wp_send_json_error('Nonce verification failed.');
    1752     wp_die();
    1753   }
     1722  ppc3d_verify_admin_ajax();
    17541723
    17551724  // Validate required fields
    … …  
    18081777function ppc3d_delete_infill_option_callback()
    18091778{
    1810   // Verify nonce
    1811   if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1812     // Nonce verification failed
    1813     wp_die('Nonce verification failed. Please refresh the page and try again.');
    1814   }
     1779  ppc3d_verify_admin_ajax();
    18151780  if (isset($_POST['optionName'])) {
    18161781    $optionName = sanitize_text_field(wp_unslash($_POST['optionName']));
    … …  
    18841849function ppc3d_add_color_option_callback()
    18851850{
    1886   // Verify nonce
    1887   if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1888     // Nonce verification failed
    1889     wp_die('Nonce verification failed. Please refresh the page and try again.');
    1890   }
     1851  ppc3d_verify_admin_ajax();
    18911852  // Check if required fields are set
    18921853  if (!isset($_POST['color'], $_POST['color_value'], $_POST['color_description'], $_POST['color_price'])) {
    … …  
    19321893function ppc3d_edit_color_option_callback()
    19331894{
    1934   // Verify nonce
    1935   if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    1936     wp_send_json_error('Nonce verification failed.');
    1937     wp_die();
    1938   }
     1895  ppc3d_verify_admin_ajax();
    19391896
    19401897  // Validate required fields
    … …  
    20031960function ppc3d_delete_color_option_callback()
    20041961{
    2005   // Verify nonce
    2006   if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) {
    2007     // Nonce verification failed
    2008     wp_die('Nonce verification failed. Please refresh the page and try again.');
    2009   }
     1962  ppc3d_verify_admin_ajax();
    20101963  if (isset($_POST['optionName'])) {
    20111964    $optionName = sanitize_text_field(wp_unslash($_POST['optionName']));
    … …  
    20381991function ppc3d_save_setting_callback()
    20391992{
    2040   // Check nonce for security
    2041   if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ppc3d_upload_stl_nonce')) {
    2042     wp_send_json_error('Security check failed');
    2043   }
     1993  ppc3d_verify_admin_ajax();
    20441994
    20451995  // Get option name and value
    … …  
    42524202function ppc3d_update_toggle_option_callback()
    42534203{
    4254   // Check nonce for security
    4255   if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ppc3d_upload_stl_nonce')) {
    4256     wp_send_json_error('Security check failed');
    4257   }
     4204  ppc3d_verify_admin_ajax();
    42584205
    42594206  // Get option name and value
  • 3d-print-pricing-calculator/trunk/includes/stl-parser-engine.php

    r3572835 r3835028  
    3131    $file = fopen($file_path, 'r');
    3232    if (! $file) {
    33         throw new RuntimeException('Unable to open STL file: ' . $file_path);
     33        throw new RuntimeException('Unable to open STL file.');
    3434    }
    3535
    3636    fseek($file, 80);
    37     $triangles = unpack('V', fread($file, 4))[1];
     37    $count_bytes = fread($file, 4);
     38    if (false === $count_bytes || 4 !== strlen($count_bytes)) {
     39        fclose($file);
     40        throw new RuntimeException('Invalid STL file.');
     41    }
     42    $triangles = unpack('V', $count_bytes)[1];
     43
     44    $file_size = filesize($file_path);
     45    if (false === $file_size || $triangles < 1 || $file_size < 84 + ($triangles * 50)) {
     46        fclose($file);
     47        throw new RuntimeException('Invalid STL file.');
     48    }
    3849
    3950    for ($i = 0; $i < $triangles; $i++) {
  • 3d-print-pricing-calculator/trunk/js/script.js

    r3632805 r3835028  
    2828  function disableGamepadAPI() {
    2929    if (!window.BABYLON) return;
    30 
     30   
    3131    try {
    32       if (navigator && typeof navigator.getGamepads === "function") {
    33         Object.defineProperty(navigator, "getGamepads", {
    34           value: function () {
    35             return [];
    36           },
    37           writable: false,
    38           configurable: true,
    39         });
    40       }
    41 
     32      // Create safe mock implementations
     33      var noopFn = function() {};
     34      var emptyArray = function() { return []; };
     35      var mockObservable = { add: noopFn, remove: noopFn, clear: noopFn };
     36     
     37      // Completely disable GamepadManager
     38      BABYLON.GamepadManager = function() {
     39        this.onGamepadConnectedObservable = mockObservable;
     40        this.onGamepadDisconnectedObservable = mockObservable;
     41        this.getGamepads = emptyArray;
     42        this.dispose = noopFn;
     43        this.getGamepadByType = emptyArray;
     44      };
     45     
     46      // Disable gamepad in Engine
     47      if (BABYLON.Engine) {
     48        var originalEngineConstructor = BABYLON.Engine;
     49        BABYLON.Engine = function() {
     50          var engine = originalEngineConstructor.apply(this, arguments);
     51          if (engine.gamepadManager) {
     52            engine.gamepadManager = new BABYLON.GamepadManager();
     53          }
     54          return engine;
     55        };
     56        BABYLON.Engine.prototype = originalEngineConstructor.prototype;
     57      }
     58     
     59      // Patch DeviceSourceManager
    4260      if (BABYLON.DeviceSourceManager) {
    43         BABYLON.DeviceSourceManager.prototype.getGamepadSource = function () {
    44           return null;
    45         };
    46         BABYLON.DeviceSourceManager.prototype.getGamepads = function () {
    47           return [];
    48         };
    49       }
    50 
    51       console.log("Gamepad API access disabled for Babylon.js");
     61        BABYLON.DeviceSourceManager.prototype.getGamepadSource = function() { return null; };
     62        BABYLON.DeviceSourceManager.prototype.getGamepads = emptyArray;
     63      }
     64     
     65      console.log('Gamepad API access disabled for Babylon.js');
    5266    } catch (e) {
    53       console.log("Error disabling Babylon.js gamepad API:", e);
    54     }
    55   }
    56 
     67      console.log('Error disabling Babylon.js gamepad API:', e);
     68    }
     69  }
    5770 
    5871  // Try to disable immediately
  • 3d-print-pricing-calculator/trunk/js/view-transitions.js

    r3632805 r3835028  
    175175                // Prepare the data for the API call
    176176                var requestData = {
    177                     fullName: fullName,
    178                     email: userEmail,
    179                     shippingAddress: shippingAddress,
    180                     transient_key_field: transientKey,
    181                     owner_email: ppc3d_stl_parser_3d.admin_email || "",
    182                     formated_data: transientData.data.formated_data || {},
    183                     rootUrl: transientData.data.rootUrl || "",
    184                     url: transientData.data.url || "",
    185                     fileName: transientData.data.fileName || "",
    186                     selectedFormDataNames: transientData.data.selectedFormDataNames || {},
     177                  fullName: fullName,
     178                  email: userEmail,
     179                  shippingAddress: shippingAddress,
     180                  transient_key_field: transientKey,
     181                  owner_email: ppc3d_stl_parser_3d.admin_email || "",
     182                  user_email: userEmail,
     183                  formated_data: transientData.data.formated_data || {},
     184                  rootUrl: transientData.data.rootUrl || "",
     185                  url: transientData.data.url || "",
     186                  fileName: transientData.data.fileName || "",
     187                  selectedFormDataNames:
     188                    transientData.data.selectedFormDataNames || {},
     189                  customer: {
     190                    name: fullName,
     191                    address: shippingAddress,
     192                    phone: "", // Not collected in the form, but required in the API structure
     193                  },
    187194                };
    188195               
  • 3d-print-pricing-calculator/trunk/readme.md

    r3632805 r3835028  
    22
    33Contributors: odysse.io
    4 Tested up to: 6.8.1
     4Tested up to: 7.1
    55Requires at least: 5.7
    66Requires PHP: 7.4
    7 Stable tag: 1.4.8.9
     7Stable tag: 1.4.9.0
    88License: GPL-3.0
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
    … …  
    8989== Changelog ==
    9090
    91 = 1.4.8.9 =
    92 
    93 - Fixed rendering and checkout errors
    94 
    95 = 1.4.8.8 =
    96 
    97 - Fixed currency symbol issues.
     91= 1.4.9.0 =
     92
     93- Security: Fixed an unauthenticated file deletion vulnerability in the STL upload handler (CVE-2026-119231). Existing files are no longer deleted before an upload is validated.
     94- Security: Updated uploads so WordPress validates the file first, only .stl files are accepted, and files are stored under a unique server-generated filename.
     95- Security: Fixed admin AJAX actions so they require the manage_options capability, and added a separate admin-only nonce. The public front-end nonce can no longer be used for admin actions.
     96- Security: Fixed the quote REST endpoint so it only returns this plugin's own quote data.
     97- Security: Updated the order endpoint to require a valid email address and a valid quote, and to accept one submission per quote.
     98- Security: Fixed the admin file manager so it can only delete tracked .stl files inside the uploads directory.
     99- Security: Updated the email template settings to check user capability and sanitize HTML.
     100- Security: Added STL file size and triangle count validation before parsing.
     101- Security: Removed debug logging of customer data, detailed error messages, and the global latest-quote transient.
     102- Removed unused AJAX hooks that pointed to a function that does not exist.
     103- Fixed the 3D viewer failing to load with newer Babylon.js builds by pinning Babylon.js to version 7.25.1.
     104- Fixed the checkout form so the customer name, email, shipping address, and quote key are sent in the format the server expects.
     105- Updated admin scripts to load only for users who can manage the plugin.
     106- Updated "Tested up to" to WordPress 7.1.
    98107
    99108= 1.4.0 =
    … …  
    210219- Initial public release of the plugin, introducing core features and functionality.
    211220
     221== Upgrade Notice ==
     222
     223= 1.4.9.0 =
     224Security release. Fixes an unauthenticated file deletion vulnerability and missing permission checks on admin actions. Please update immediately.
     225
    212226== Screenshots ==
    213227
    … …  
    224238This plugin uses Babylon.js for 3D model rendering and loads it from the CDN for optimal performance and minimal plugin footprint:
    225239
    226 - **Babylon.js CDN**: [https://cdn.babylonjs.com/babylon.js](https://cdn.babylonjs.com/babylon.js)
    227 - **Babylon.js Loaders CDN**: [https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js](https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js)
     240- **Babylon.js CDN**: [https://cdn.babylonjs.com/v7.25.1/babylon.js](https://cdn.babylonjs.com/v7.25.1/babylon.js)
     241- **Babylon.js Loaders CDN**: [https://cdn.babylonjs.com/v7.25.1/loaders/babylonjs.loaders.min.js](https://cdn.babylonjs.com/v7.25.1/loaders/babylonjs.loaders.min.js)
    228242
    229243Babylon.js is licensed under the Apache License 2.0. For more information, visit [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
  • 3d-print-pricing-calculator/trunk/templates/upload-form.php

    r3591192 r3835028  
    102102        <div class="form-selections">
    103103          <div class="form-selections-heading">
    104             <span id="checkout-total-price"><?php echo esc_html(get_option('ppc3d_currency_symbol', '$')); ?>00.00</span>
     104            <span id="checkout-total-price">$00.00</span>
    105105
    106106            <!-- <button id="removeMesh" type="button" class="reset-button">Reset</button> -->
    … …  
    295295                <li class="price-item">
    296296                  <span class="price-label">Estimated Price:</span>
    297                   <span class="price-value" id="estimated-price-view"><?php echo esc_html(get_option('ppc3d_currency_symbol', '$')); ?>0.00</span>
     297                  <span class="price-value" id="estimated-price-view">$0.00</span>
    298298                </li>
    299299                <li class="price-item">
    300300                  <span class="price-label">Shipping Price:</span>
    301                   <span class="price-value" id="shipping-price-view"><?php echo esc_html(get_option('ppc3d_currency_symbol', '$')); ?>0.00</span>
     301                  <span class="price-value" id="shipping-price-view">$0.00</span>
    302302                </li>
    303303              </ul>
    304304              <div class="price-container">
    305305                <span class="total-label">Total Price:</span>
    306                 <span class="total-value" id="checkout-total-price-view"><?php echo esc_html(get_option('ppc3d_currency_symbol', '$')); ?>00.00</span>
     306                <span class="total-value" id="checkout-total-price-view">$00.00</span>
    307307              </div>
    308308            </div>
Note: See TracChangeset for help on using the changeset viewer.