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

Improve Parser backward compatibility #13310

Closed
pento opened this issue Jan 13, 2019 · 1 comment
Closed

Improve Parser backward compatibility #13310

pento opened this issue Jan 13, 2019 · 1 comment
Assignees
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f [Type] Bug An existing feature does not function as intended

Comments

@pento
Copy link
Member

pento commented Jan 13, 2019

Describe the bug

The regular expression that the PHP parser uses the (?<name>pattern) syntax to create named subpatterns. This syntax was introduced in PHP 5.2.2.

$has_match = preg_match(
'/<!--\s+(?<closer>\/)?wp:(?<namespace>[a-z][a-z0-9_-]*\/)?(?<name>[a-z][a-z0-9_-]*)\s+(?<attrs>{(?:(?:[^}]+|}+(?=})|(?!}\s+\/?-->).)*+)?}\s+)?(?<void>\/)?-->/s',
$this->document,
$matches,
PREG_OFFSET_CAPTURE,
$this->offset
);

Strictly speaking, however, the syntax was introduced in PCRE 7.0, which is the default version of PCRE built into PHP 5.2.2, but some Linux distros (Centos 5 is a known example) use an older PCRE. In the case of Centos 5, they use PCRE 6.6.

In core (as well as in other places in Gutenberg), we've avoided this problem by using the older (?P<name>pattern) syntax.

I'd like to get this fixed in WordPress 5.1.

Ref: https://core.trac.wordpress.org/ticket/45644

@pento pento added [Type] Bug An existing feature does not function as intended [Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f Backwards Compatibility Issues or PRs that impact backwards compatability labels Jan 13, 2019
@mcsf mcsf self-assigned this Jan 17, 2019
@mcsf
Copy link
Contributor

mcsf commented Jan 17, 2019

Thanks for surfacing and providing context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backwards Compatibility Issues or PRs that impact backwards compatability [Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants