Make WordPress Core

Opened 4 years ago

Last modified 8 weeks ago

#51019 new defect (bug)

convert_smilies() fails on large tags

Reported by: podpirate's profile podpirate Owned by:
Milestone: 6.6 Priority: normal
Severity: normal Version: 5.5
Component: Formatting Keywords: has-patch needs-unit-tests php80 changes-requested
Focuses: Cc:

Description

I have an image with huge data-url src (1.6M) in the post content.
The post content is not displayed, but (with WP_DEBUG on) there is a php error instead.

PHP Error output:

 Warning: count(): Parameter must be an array or an object that implements Countable in /Users/joern/www/vhosts/wordpress.local/httpdocs/stable/wp-includes/formatting.php on line 3357

Som digging revealed, that preg_split() in function convert_smilies() fails with a PREG_RECURSION_LIMIT_ERROR.

IMHO there should a check for preg_last_error() whether preg_split() was successfull, and if not the function should just return its input.

Any thoughts on this?
I'd be happy to craft a patch.

Change History (16)

#1 @SergeyBiryukov
4 years ago

  • Component changed from General to Formatting
  • Keywords needs-patch added

Hi there, welcome back to WordPress Trac! Thanks for the ticket.

IMHO there should a check for preg_last_error() whether preg_split() was successfull, and if not the function should just return its input.

Makes sense to me :)

This ticket was mentioned in PR #792 on WordPress/wordpress-develop by nathkrill.


3 years ago
#2

  • Keywords has-patch added; needs-patch removed

…o avoid issues in ticket #51019

Use preg_last_error() inside convert_smilies() to check for any preg_split errors before running count().
If there are errors, sends a PHP warning with the error message, then returns the original text.

Running count() on the array after there are preg_split errors can cause post content to not display (see ticket).

Trac ticket: https://core.trac.wordpress.org/ticket/51019

github-actions[bot] commented on PR #792:


3 years ago
#3

Hi @nathkrill! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in this blog post.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

This ticket was mentioned in PR #1124 on WordPress/wordpress-develop by nathkrill.


3 years ago
#4

Use preg_last_error() inside convert_smilies() to check for any preg_split errors before running count().
If there are errors, sends a PHP warning with the error message, then returns the original text.

Running count() on the array after there are preg_split errors can cause post content to not display (see ticket).

This is a reformat of a previous pull request to get the PHP tests to pass.

Trac ticket: https://core.trac.wordpress.org/ticket/51019

borzaszto commented on PR #1124:


2 years ago
#5

Same, +1 Up 🙌

lzudor-omnitech commented on PR #1124:


2 years ago
#6

Is there any ETA on this..?

#7 @rupw
18 months ago

FWIW I'd probably just check $textarr === false rather than preg_last_error(), but looks good to me.

Another report on WPSE: https://wordpress.stackexchange.com/q/409084

#8 @jorbin
4 months ago

#59927 was marked as a duplicate.

#9 @jorbin
4 months ago

  • Keywords needs-unit-tests php80 added
  • Milestone changed from Awaiting Review to 6.5

I would like for there to be an automated test for this, but otherwise, it is something that should be fixed for 6.5.

#10 @swissspidy
2 months ago

  • Keywords needs-refresh added

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


2 months ago

#12 @audrasjb
2 months ago

  • Keywords changes-requested added; needs-refresh removed

As per today's bugscrub:
Some changes were requested in the current PR, and it still needs unit tests. Let's keep it in the milestone for a week.

@audrasjb commented on PR #1124:


2 months ago
#13

@nathkrill are you able to refresh your PR with the requested changes? Thank you!

This ticket was mentioned in Slack in #core by rajinsharwar. View the logs.


2 months ago

#15 @rajinsharwar
2 months ago

Let's keep this in the milestone for some more days, and if there is still not much activity, we might need to bump this again.

#16 @swissspidy
8 weeks ago

  • Milestone changed from 6.5 to 6.6
Note: See TracTickets for help on using tickets.