Plugin Directory

Changeset 3470986


Ignore:
Timestamp:
02/27/2026 10:53:00 AM (5 weeks ago)
Author:
instarank
Message:

v2.0.7: Fix blank page content caused by PCRE backtracking limit on large Kadence blocks

Location:
instarank/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • instarank/trunk/api/endpoints.php

    r3470975 r3470986  
    51325132        $index = 0;
    51335133
    5134         // Protect JSON inside block comments by replacing with placeholders
    5135         // Matches JSON objects between block comment opening and closing delimiters
     5134        // Protect JSON inside block comments by replacing with placeholders.
     5135        // Uses a non-backtracking approach: match the block comment start,
     5136        // then capture everything up to the closing --> delimiter.
    51365137        $protected = preg_replace_callback(
    5137             '/(?<=<!-- wp:[a-z0-9\/-]+ )(\{[\s\S]*?\})(?=\s*\/-->|\s*-->)/i',
     5138            '/(<!-- wp:[a-z0-9\/-]+ )(\{[^}]*(?:\}(?!\s*(?:\/-->|-->))[^}]*)*\})(\s*\/-->|\s*-->)/i',
    51385139            function($matches) use (&$placeholders, &$index) {
    51395140                $placeholder = "___BLOCK_JSON_{$index}___";
    5140                 $placeholders[$placeholder] = $matches[0];
     5141                $placeholders[$placeholder] = $matches[2];
    51415142                $index++;
    5142                 return $placeholder;
     5143                return $matches[1] . $placeholder . $matches[3];
    51435144            },
    51445145            $content
    51455146        );
     5147
     5148        // If preg_replace_callback failed (PCRE backtracking limit), return original
     5149        if ($protected === null) {
     5150            error_log('[InstaRank] decode_entities_outside_block_json: preg_replace_callback failed (PCRE limit), returning original content');
     5151            return $content;
     5152        }
    51465153
    51475154        // Safely decode entities on everything (JSON is protected by placeholders)
     
    51675174        $index = 0;
    51685175
    5169         // Protect JSON inside block comments
     5176        // Protect JSON inside block comments using non-backtracking pattern
    51705177        $protected = preg_replace_callback(
    5171             '/(?<=<!-- wp:[a-z0-9\/-]+ )(\{[\s\S]*?\})(?=\s*\/-->|\s*-->)/i',
     5178            '/(<!-- wp:[a-z0-9\/-]+ )(\{[^}]*(?:\}(?!\s*(?:\/-->|-->))[^}]*)*\})(\s*\/-->|\s*-->)/i',
    51725179            function($matches) use (&$placeholders, &$index) {
    51735180                $placeholder = "___BLOCK_JSON_ESC_{$index}___";
    5174                 $placeholders[$placeholder] = $matches[0];
     5181                $placeholders[$placeholder] = $matches[2];
    51755182                $index++;
    5176                 return $placeholder;
     5183                return $matches[1] . $placeholder . $matches[3];
    51775184            },
    51785185            $content
    51795186        );
     5187
     5188        // If preg_replace_callback failed (PCRE backtracking limit), return original
     5189        if ($protected === null) {
     5190            error_log('[InstaRank] replace_escapes_outside_block_json: preg_replace_callback failed (PCRE limit), returning original content');
     5191            return $content;
     5192        }
    51805193
    51815194        // Safely replace escape sequences in non-JSON content
  • instarank/trunk/instarank.php

    r3470975 r3470986  
    44 * Plugin URI: https://instarank.com/wordpress-plugin
    55 * Description: Connect your WordPress site to InstaRank for AI-powered SEO optimization, schema markup generation, and programmatic SEO. Create and sync custom post types, automatically apply SEO improvements, and generate structured data with InstaRank's AI engine.
    6  * Version: 2.0.6
     6 * Version: 2.0.7
    77 * Author: InstaRank
    88 * Author URI: https://instarank.com
     
    1818
    1919// Define plugin constants
    20 define('INSTARANK_VERSION', '2.0.6');
     20define('INSTARANK_VERSION', '2.0.7');
    2121define('INSTARANK_PLUGIN_DIR', plugin_dir_path(__FILE__));
    2222define('INSTARANK_PLUGIN_URL', plugin_dir_url(__FILE__));
  • instarank/trunk/readme.txt

    r3470975 r3470986  
    44Requires at least: 5.6
    55Tested up to: 6.9
    6 Stable tag: 2.0.6
     6Stable tag: 2.0.7
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    169169
    170170== Changelog ==
     171
     172= 2.0.7 =
     173* Fix: Blank page content caused by PCRE backtracking limit failure on large Kadence blocks
     174* Fix: Replaced catastrophic-backtracking regex with efficient non-backtracking pattern
     175* Fix: Added null-check fallback for preg_replace_callback failure
    171176
    172177= 2.0.6 =
Note: See TracChangeset for help on using the changeset viewer.