WordPress.org

Make WordPress Core

Changeset 35709


Ignore:
Timestamp:
11/19/2015 11:31:00 PM (4 years ago)
Author:
pento
Message:

Texturize: Only convert & to & within text nodes.

Previously, & would be converted everywhere, which caused problems when it was converted within a <script>, for example.

convert_chars() is now removed from the the_content filter, as it was doing the same job as wptexturize().

KSES correctly handles converting & within HTML attributes, so there's no need for wptexturize() and convert_chars() to do the same job.

Fixes #34698.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r35689 r35709  
    132132add_filter( 'the_content', 'wptexturize'                       );
    133133add_filter( 'the_content', 'convert_smilies'                   );
    134 add_filter( 'the_content', 'convert_chars'                     );
    135134add_filter( 'the_content', 'wpautop'                           );
    136135add_filter( 'the_content', 'shortcode_unautop'                 );
  • trunk/src/wp-includes/formatting.php

    r35555 r35709  
    277277                $curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1&#215;$2', $curl );
    278278            }
    279         }
    280     }
    281     $text = implode( '', $textarr );
    282 
    283     // Replace each & with &#038; unless it already looks like an entity.
    284     return preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&#038;', $text );
     279
     280            // Replace each & with &#038; unless it already looks like an entity.
     281            $curl = preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&#038;', $curl );
     282        }
     283    }
     284
     285    return implode( '', $textarr );
    285286}
    286287
  • trunk/tests/phpunit/tests/formatting/WPTexturize.php

    r34761 r35709  
    12681268            ),
    12691269            array(
    1270                 '[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a> ]',
    1271                 '[ photos by <a href="http://example.com/?a[]=1&#038;a[]=2"> this guy </a> ]',
    1272             ),
    1273             array(
    1274                 '[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a>]',
    1275                 '[photos by <a href="http://example.com/?a[]=1&#038;a[]=2"> this guy </a>]',
     1270                '[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a> ]',
     1271                '[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy &#038; that guy </a> ]',
     1272            ),
     1273            array(
     1274                '[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy & that guy </a>]',
     1275                '[photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy &#038; that guy </a>]',
    12761276            ),
    12771277            array(
Note: See TracChangeset for help on using the changeset viewer.