Plugin Directory

Changeset 3344310


Ignore:
Timestamp:
08/14/2025 05:42:00 AM (7 months ago)
Author:
ferranfg
Message:

Release 2.19.1

Location:
mpl-publisher/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • mpl-publisher/trunk/helpers.php

    r3001142 r3344310  
    275275    }
    276276}
     277
     278if ( ! function_exists('mpl_sanitize_filename'))
     279{
     280    function mpl_sanitize_filename($filename)
     281    {
     282        // Remove or replace characters that are invalid in file names
     283        $filename = str_replace(
     284            array('/', '\\', ':', '*', '?', '"', "'", '<', '>', '|'),
     285            array('-', '-', '-', '-', '-', '', '', '', '', '-'),
     286            $filename
     287        );
     288       
     289        // Remove multiple consecutive dashes and trim
     290        $filename = preg_replace('/-+/', '-', $filename);
     291        $filename = trim($filename, '- ');
     292       
     293        // Ensure filename is not empty
     294        if (empty($filename)) {
     295            $filename = 'untitled';
     296        }
     297       
     298        return $filename;
     299    }
     300}
  • mpl-publisher/trunk/libs/PremiumPublisher.php

    r3001142 r3344310  
    102102    public function request($endpoint, $filename)
    103103    {
    104         $filepath = $this->tempPath . '/' . $filename;
     104        $filepath = $this->tempPath . '/' . mpl_sanitize_filename($filename);
    105105        $authorization = is_null(mpl_premium_license()) ? mpl_premium_token() : mpl_premium_license();
    106106
     
    123123        {
    124124            header('Content-Description: File Transfer');
    125             header('Content-Disposition: attachment; filename="' . $filename . '"');
     125            header('Content-Disposition: attachment; filename="' . mpl_sanitize_filename($filename) . '"');
    126126            header('Content-Transfer-Encoding: binary');
    127127            header('Content-Length: ' . filesize($filepath));
  • mpl-publisher/trunk/libs/WordPublisher.php

    r3001142 r3344310  
    151151    public function send($filename)
    152152    {
    153         $filepath = $this->tempPath . '/' . $filename . '.docx';
     153        $filepath = $this->tempPath . '/' . mpl_sanitize_filename($filename) . '.docx';
    154154
    155155        $writer = IOFactory::createWriter($this->word, 'Word2007');
     
    159159        // https://github.com/PHPOffice/PHPWord/issues/449
    160160        header('Content-Description: File Transfer');
    161         header('Content-Disposition: attachment; filename="' . $filename . '.docx"');
     161        header('Content-Disposition: attachment; filename="' . mpl_sanitize_filename($filename) . '.docx"');
    162162        header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
    163163        header('Content-Transfer-Encoding: binary');
  • mpl-publisher/trunk/mpl-publisher.php

    r3288277 r3344310  
    44 * Plugin URI: https://wordpress.mpl-publisher.com/
    55 * Description: MPL-Publisher 📚 creates an ebook, print-ready PDF book, EPUB for KDP, or Audiobook MP3 directly from your WordPress posts.
    6  * Version: 2.19.0
     6 * Version: 2.19.1
    77 * Author: Ferran Figueredo
    88 * Author URI: https://ferranfigueredo.com
  • mpl-publisher/trunk/readme.txt

    r3288277 r3344310  
    66Tested up to: 6.8
    77Requires PHP: 7.4
    8 Stable tag: 2.19.0
     8Stable tag: 2.19.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    127127== Changelog ==
    128128
     129= 2.19.1 =
     130- Fixed error when book title contains a slash
     131
    129132= 2.19.0 =
    130133- Added support for selecting and sorting multiple chapters simultaneously
Note: See TracChangeset for help on using the changeset viewer.