Making WordPress.org

Changeset 10566


Ignore:
Timestamp:
01/11/2021 02:54:14 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Readme parser: Don't attempt to pass too-long-a-string to file_exists() to avoid PHP warnings.

A string containing a new line is also definately not a file we want to parse either.

Props afragen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php

    r10565 r10566  
    160160         */
    161161        public function __construct( $string ) {
    162                 if ( file_exists( $string )
     162                if (
     163                        (
     164                                // If it's longer than the Filesystem path limit or contains newlines, it's not worth a file_exists() check.
     165                                strlen( $string ) <= PHP_MAXPATHLEN
     166                                && false === strpos( $string, "\n" )
     167                                && file_exists( $string )
     168                        )
    163169                        || preg_match( '!^https?://!i', $string )
    164170                        || preg_match( '!^data:text/plain!i', $string) )
Note: See TracChangeset for help on using the changeset viewer.