Making WordPress.org

Changeset 9937


Ignore:
Timestamp:
05/28/2020 05:45:32 AM (5 years ago)
Author:
tellyworth
Message:

Plugin dir: improve detection of blocks in code.

Use a more flexible regex for catching registerBlockType calls in JS code, especially minified code.

See #5207

File:
1 edited

Legend:

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

    r9934 r9937  
    636636            // Note that this only works with literal strings for the block name and title, and assumes that order.
    637637            $contents = file_get_contents( $filename );
    638             if ( $contents && preg_match_all( "#registerBlockType\s*[(]\s*'([-\w]+/[-\w]+)'\s*,\s*[{]\s*title\s*:[\s_(]*'([^']*)'#ms", $contents, $matches, PREG_SET_ORDER ) ) {
     638            if ( $contents && preg_match_all( "#registerBlockType[^{}]{0,500}[(]\s*[\"']([-\w]+/[-\w]+)[\"']\s*,\s*[{]\s*title\s*:[\s\w(]*[\"']([^\"']*)[\"']#ms", $contents, $matches, PREG_SET_ORDER ) ) {
    639639                foreach ( $matches as $match ) {
    640640                    $blocks[] = (object) [
Note: See TracChangeset for help on using the changeset viewer.