WordPress.org

Make WordPress Core

Opened 3 weeks ago

Last modified 3 weeks ago

#44278 new defect (bug)

Smileys got rendered inside pre/code tags in case html attributes are added to the tag

Reported by: Andi Dittrich Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Formatting Keywords: has-patch dev-feedback needs-unit-tests
Focuses: Cc:

Description

hi!

in case "raw" content is posted in a pre tag, legacy smiley sequences are processed by the convert_smilies function and converted to images, even if the html tags are in the $tags_to_ignore list.

this is caused by a weak regex inside the function which didn't take care of html attributes

current behaviour https://media.andidittrich.de/wp-trac/current.png

expected behaviour https://media.andidittrich.de/wp-trac/expected.png

example content to reproduce the issue

hello :)

this is sourcecode and should not contain smiley images:
<pre class="EnlighterJSRAW" data-enlighter-language="js">alert(':)');
// :)</pre>
and text :(

attached a fixed version which is taking care of additional html attributes

best regards, Andi

Attachments (2)

convert_smilies_regex.patch (598 bytes) - added by Andi Dittrich 3 weeks ago.
patch to fix the regex
convert_smilies_regex_v2.patch (597 bytes) - added by Andi Dittrich 3 weeks ago.
removed repetition quantifier (regex should be ungreedy)

Download all attachments as: .zip

Change History (4)

@Andi Dittrich
3 weeks ago

patch to fix the regex

@Andi Dittrich
3 weeks ago

removed repetition quantifier (regex should be ungreedy)

#1 @birgire
3 weeks ago

  • Keywords needs-unit-tests added
  • Version trunk deleted

Thanks for the ticket and patch @Andi Dittrich

There is already ticket #16448 that is marked as fixed, so did something change since then?

#2 @Andi Dittrich
3 weeks ago

the old ticket adds the generic functionality to exclude pre/code tags from convert_smilies. but it uses a weak regex which didn't handle html attributes on these tags.

this patch fixes the feature introduced in #16448 by modifying the regex

Note: See TracTickets for help on using tickets.