From 74a774e8e7a13d8c87e1dcde71c25ce60455aec3 Mon Sep 17 00:00:00 2001 From: Matt Wiebe Date: Wed, 1 Nov 2023 10:53:27 -0500 Subject: [PATCH] Hashtags: 1MB limit for attempting to link (#544) --- includes/class-hashtag.php | 4 ++++ readme.txt | 1 + 2 files changed, 5 insertions(+) diff --git a/includes/class-hashtag.php b/includes/class-hashtag.php index 2d03ac4..6031d1f 100644 --- a/includes/class-hashtag.php +++ b/includes/class-hashtag.php @@ -43,6 +43,10 @@ class Hashtag { * @return string the filtered post-content */ public static function the_content( $the_content ) { + // small protection against execution timeouts: limit to 1 MB + if ( mb_strlen( $the_content ) > MB_IN_BYTES ) { + return $the_content; + } $tag_stack = array(); $protected_tags = array( 'pre', diff --git a/readme.txt b/readme.txt index ec1af3b..5a70498 100644 --- a/readme.txt +++ b/readme.txt @@ -110,6 +110,7 @@ Project maintained on GitHub at [automattic/wordpress-activitypub](https://githu * Improved: audio and video attachments are now supported! * Improved: better error messages if remote profile is not accessible * Improved: PHP 8.1 compatibility +* Fixed: don't try to parse mentions or hashtags for very large (>1MB) posts to prevent timeouts = 1.0.10 =