WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #26626


Ignore:
Timestamp:
12/15/2013 11:13:52 AM (7 years ago)
Author:
SergeyBiryukov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26626 – Description

    initial v1  
    77See http://wordpress.org/support/topic/restore-fails-could-not-create-directory for more information on that. Basically, it boiled down to "WP_Upgrader::unpack_package() uses the basename of the zip file to create a directory in WP_CONTENT_DIR/upgrade/". So, if the zip file name is very long, then a meaningful amount of the potential 256-character limit can be lost.
    88
    9 The guy running Bitnami lost 80 characters to reach his upgrade folder: C:\Program Files\BitNami WAMP Stack\apps\wordpresslucid\htdocs\wp-content/upgrade. That leaves 176 characters.
     9The guy running Bitnami lost 80 characters to reach his upgrade folder: `C:\Program Files\BitNami WAMP Stack\apps\wordpresslucid\htdocs\wp-content/upgrade`. That leaves 176 characters.
    1010
    11 The plugin he was unpacking needed 98 characters for its longest pathname: /plugins/<slug>/opencloud/symed/Symfony/Component/EventDispatcher/EventDispatcherInterface.php. That leaves 78 characters to spare. Should be plenty... except for WP_Upgrader::unpack_package() wanting to use basename($zipfile) to create a directory for unpacking into. The zipfile did indeed have a filename of over 78 characters long. Boom!
     11The plugin he was unpacking needed 98 characters for its longest pathname: `/plugins/<slug>/opencloud/symed/Symfony/Component/EventDispatcher/EventDispatcherInterface.php`. That leaves 78 characters to spare. Should be plenty... except for WP_Upgrader::unpack_package() wanting to use basename($zipfile) to create a directory for unpacking into. The zipfile did indeed have a filename of over 78 characters long. Boom!
    1212
    1313To prevent other scenarios in which someone might get hit by this, we can just change this line:
    14 
     14{{{
    1515$working_dir = $upgrade_folder . basename($package, '.zip');
    16 
     16}}}
    1717to:
    18 
     18{{{
    1919$working_dir = $upgrade_folder . substr(md5(basename($package, '.zip')), 0, 8);
    20 
     20}}}
    2121The use of md5() to prevent collisions might be over-cautious (especially given that WP_Upgrader::unpack_package() already tries to empty out the upgrades directory), but it's also harmless.