ezyang / ezyang/htmlpurifier

Deprecations for preg_match, preg_replace_callback and null argument

Open
#385 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.4k
Forks
361
Avg merge
3d 41m
Merged PRs (30d)
2

Description

Seeing this in php8.2

1 PHP Deprecated:  preg_replace_callback(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php on line 57
1 PHP Deprecated:  preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer.php on line 373
1 PHP Deprecated:  preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /vendor/ezyang/htmlpurifier/library/HTMLPurifier/Encoder.php on line 139

Looks like all are cases of the code expecting a string but somewhere allowing null.

php docs do not indicate when this was deprecated, just indicates those parameters should be string|array.

Probably somewhere further up the stack a null check could clear this up.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported calls in library/HTMLPurifier/Lexer/DOMLex.php:57, library/HTMLPurifier/Lexer.php:373, and library/HTMLPurifier/Encoder.php:139, then trace their callers to identify where null reaches the regular-expression functions. Done means PHP 8.2 no longer reports these deprecations while the affected filtering behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.