[wp-trac] [WordPress Trac] #51019: convert_smilies() fails on large tags
WordPress Trac
noreply at wordpress.org
Wed Jun 12 04:50:52 UTC 2024
#51019: convert_smilies() fails on large tags
-------------------------------------------------+-------------------------
Reporter: podpirate | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.6
Component: Formatting | Version: 5.5
Severity: normal | Resolution:
Keywords: has-patch php80 has-unit-tests has- | Focuses:
testing-info needs-testing |
-------------------------------------------------+-------------------------
Changes (by rajinsharwar):
* keywords: has-patch php80 changes-requested has-unit-tests => has-patch
php80 has-unit-tests has-testing-info needs-testing
Comment:
I added a new PR along with the unit tests. So, I am just bailing out and
returning the input text directly, if the preg_replace fails. Added a unit
test as well.
I removed the part to show the error message, because the
preg_last_error_msg() was introduced in PHP 8, and users with PHP 7 or
before will encounter a Fatal error.
Also, we can also use some switch statements to use the preg_last_error()
error code, to display error messages based on those. But, I think that
would introduce so many strings, and much more complexity than required,
for this edge case.
Feel free to share your thoughts if you think we should output the error
message as well. 🙂
**Testing instructions:**
1. Enable WP_DEBUG
2. Add the below code in functions.php
{{{
function test(){
$text = '<p><img alt="" src="data:image/png;base64,' .
str_repeat( "iVBORw0KGgoAAAAN", 99999 ) . '="></p>' ;
convert_smilies( $text );
}
add_action( 'init', 'test' );
}}}
You will notice some Fatal errors.
3. Apply the patch, and repeat the process. You shouldn't notice any Fatal
error.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51019#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list