WordPress.org

Make WordPress Core

Ticket #9452: 9452.regex.patch

File 9452.regex.patch, 1.1 KB (added by jbsil, 5 years ago)
  • plugin-editor.php

     
    161161        <h3 id="bordertitle"><?php _e('Plugin Files'); ?></h3> 
    162162 
    163163        <ul> 
    164 <?php foreach($plugin_files as $plugin_file) : ?> 
     164<?php 
     165//List of allowable extensions 
     166$include = array("php", "txt", "text", "js", "css", "html", "htm", "xml", "inc", "include"); 
     167foreach($plugin_files as $plugin_file) : 
     168        //Get the extension of the file 
     169        if (preg_match('/\.([^.]+)$/', $plugin_file, $matches)) { 
     170                $ext = strtolower($matches[1]); 
     171                //If extension is not in the acceptable list, skip it 
     172                if ( false === array_search( $ext, $include ) ) continue; 
     173        } else { 
     174                //No extension found 
     175                //What action belongs here? Leave the file in the list? Going with skip for safety 
     176                continue; 
     177        }       ?> 
    165178                <li<?php echo $file == $plugin_file ? ' class="highlight"' : ''; ?>><a href="plugin-editor.php?file=<?php echo $plugin_file; ?>&plugin=<?php echo $plugin; ?>"><?php echo $plugin_file ?></a></li> 
    166179<?php endforeach; ?> 
    167180        </ul>