WordPress.org

Make WordPress Core

Ticket #42182: wp-esc-js-handle-unicode-breaks.diff

File wp-esc-js-handle-unicode-breaks.diff, 686 bytes (added by johanee, 2 years ago)
  • src/wp-includes/formatting.php

     
    39213921        $safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
    39223922        $safe_text = str_replace( "\r", '', $safe_text );
    39233923        $safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) );
     3924    if ( seems_utf8( $safe_text ) ) {
     3925        $safe_text = str_replace( array( "\xe2\x80\xa8", "\xe2\x80\xa9" ), array( "\u2028", "\u2029" ), $safe_text );
     3926    }
    39243927        /**
    39253928         * Filters a string cleaned and escaped for output in JavaScript.
    39263929         *