[wp-trac] [WordPress Trac] #18549: wp_texturize incorrectly curls closing quotes after inline HTML end tags

WordPress Trac wp-trac at lists.automattic.com
Tue Aug 30 21:54:26 UTC 2011


#18549: wp_texturize incorrectly curls closing quotes after inline HTML end tags
--------------------------+-----------------------------
 Reporter:  justincwatt   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Formatting    |    Version:  3.2.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 The following source HTML:
 {{{
 The word is "<a href="http://example.com/">quoted</a>".
 The word is '<a href="http://example.com/">quoted</a>'
 The word is '<a href="http://example.com/">quoted.</a>'
 The word is '<a href="http://example.com/">quoted</a>'.
 The word is '<a href="http://example.com/">quot</a>'d
 }}}

 Gets incorrectly transformed by wp_texturize() as:
 {{{
 The word is &#8220;<a href="http://example.com/">quoted</a>&#8220;.
 The word is &#8216;<a href="http://example.com/">quoted</a>&#8216;
 The word is &#8216;<a href="http://example.com/">quoted.</a>&#8216;
 The word is &#8216;<a href="http://example.com/">quoted</a>&#8216;.
 The word is &#8216;<a href="http://example.com/">quot</a>&#8216;d
 }}}
 '''Note:''' all the double/single quotes in the above examples that should
 be closing are instead opening)

 This renders in the browser like this:
 {{{
 The word is “quoted“.
 The word is ‘quoted‘
 The word is ‘quoted.‘
 The word is ‘quoted‘.
 The word is ‘quot‘d
 }}}

 The problem here is that wp_texturize splits the text on all start/end
 tags, which makes sense for block-level tags, but not inline-tags like
 {{{<em>}}} and {{{<a href="">}}}.

 formatting.php line 67:
 {{{
 $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1,
 PREG_SPLIT_DELIM_CAPTURE);
 }}}

 However if you change it to only split the content on block-level tags,
 you'll need something more sophisticated/complex than a regular expression
 to avoid curling quotes within html.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18549>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list