Make WordPress Core

Opened 8 years ago

Last modified 2 months ago

#39847 new defect (bug)

force_balance_tags not properly balancing < with <strong> and </strong>

Reported by: jpmerx's profile jpmerx Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.2
Component: Formatting Keywords:
Focuses: ui Cc:

Description

Given following HMTL code which includes the \[ and \] Latex delimiters:

\[<\] <strong>We</strong>

the output of force_balance_tags is

\[<\] <strong>We

which is not correct as the bold tags are unbalanced. Expected output should be the input string.

Change History (2)

#1 @jpmerx
8 years ago

  • Summary changed from force_balance_tags not properly balancing < in \[\] block to force_balance_tags not properly balancing < with <strong> and </strong>

I found an even simple string producing the error.

For following HMTL code which includes the < symbol:

< <strong>We</strong>

the output of force_balance_tags is

< <strong>We

which is not correct as the bold tags are unbalanced. Expected output should be the input string.

Last edited 8 years ago by jpmerx (previous) (diff)

#2 @dmsnell
2 months ago

@jpmerx I'm looking at replacing the internal logic of force_balance_tags() to rely on the new WP_HTML_Processor::normalize() method. That seems to resolve these issues.

<?php
echo force_balance_tags( '\[<\] <strong>We</strong>' );
// \[&lt;\] <strong>We</strong>

echo force_balance_tags( '< <strong>We</strong>' );
// &lt; <strong>We</strong>

https://github.com/WordPress/wordpress-develop/pull/7409

Note: See TracTickets for help on using tickets.