Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Grapheme polyfill is failing tests when using \X as regex for clusters #511

Open
stof opened this issue Dec 21, 2024 · 3 comments
Open

Comments

@stof
Copy link
Member

stof commented Dec 21, 2024

See CI jobs for PHP 7.3+ which are failing a test when using the polyfill:

$this->assertSame('', grapheme_substr('☢☎❄', 1, 1));

\X does not split those as separate grapheme clusters.

@stof
Copy link
Member Author

stof commented Dec 21, 2024

Apparently, the \X is correct only starting in PCRE 10.44: PCRE2Project/pcre2#410

We might need to change our condition for the usage of the fallback regex.

@Ayesh
Copy link
Contributor

Ayesh commented Dec 21, 2024

Yeah, it's only fixed in PCRE 10.44 (I was the one who reported).
This is worked around in the proposed grapheme_str_split PR. I don't think there is a way to overcome this, apart from skipping the assertions on older PCRE2 versions.

@stof
Copy link
Member Author

stof commented Dec 21, 2024

We already have some code dealing with that in

\define('SYMFONY_GRAPHEME_CLUSTER_RX', ((float) \PCRE_VERSION < 10 ? (float) \PCRE_VERSION >= 8.32 : (float) \PCRE_VERSION >= 10.39) ? '\X' : Grapheme::GRAPHEME_CLUSTER_RX);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants