Make WordPress Core

Changeset 41043 for trunk/package.json


Ignore:
Timestamp:
07/14/2017 05:46:19 AM (7 years ago)
Author:
pento
Message:

Emoji: Port the Twemoji regex to PHP.

Previously, wp_encode_emoji() and wp_staticize_emoji() used inaccurate regular expressions to find emoji, and transform then into HTML entities or <img>s, respectively. This would result in emoji not being correctly transformed, or occasionally, non-emoji being incorrectly transformed.

This commit adds a new grunt task - grunt precommit:emoji. It finds the regex in twemoji.js, transforms it into a PHP-friendly version, and adds it to formatting.php. This task is also automatically run by grunt precommit, when it detects that twemoji.js has changed.

The new regex requires features introduced in PCRE 8.32, which was introduced in PHP 5.4.14, though it was also backported to later releases of the PHP 5.3 series. For versions of PHP that don't support this, it will fall back to an updated version of the loose-matching regex.

For short posts, the performance difference between the old and new regex is negligible. As the posts get longer, however, the new method is exponentially faster.

Fixes #35293.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/package.json

    r40871 r41043  
    3131    "grunt-patch-wordpress": "~0.4.2",
    3232    "grunt-postcss": "~0.7.1",
     33    "grunt-replace": "~1.0.1",
    3334    "grunt-rtlcss": "~2.0.1",
    3435    "grunt-sass": "~1.2.1",
Note: See TracChangeset for help on using the changeset viewer.