mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-28 01:32:41 +01:00
Fix PHP 8.1 "preg_match(null)" exception for missing Content-Type
Summary: When the `Content-Type` HTTP header is empty or missing, `null` is passed to `preg_match()` which is deprecated behavior since PHP 8.1. Thus only call `preg_match()` when the value is set. ``` ERROR 8192: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated at [$HOME/arcanist/src/future/http/status/HTTPFutureHTTPResponseStatus.php:24] ``` Closes T15821 Test Plan: Visit something using `HTTPFutureHTTPResponseStatus`, like, a profile image. No crashes. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15821 Differential Revision: https://we.phorge.it/D25632
This commit is contained in:
parent
6718b32a64
commit
7f28d7266f
1 changed files with 2 additions and 1 deletions
|
@ -21,7 +21,8 @@ final class HTTPFutureHTTPResponseStatus extends HTTPFutureResponseStatus {
|
||||||
|
|
||||||
$content_type = BaseHTTPFuture::getHeader($headers, 'Content-Type');
|
$content_type = BaseHTTPFuture::getHeader($headers, 'Content-Type');
|
||||||
$match = null;
|
$match = null;
|
||||||
if (preg_match('/;\s*charset=([^;]+)/', $content_type, $match)) {
|
if (phutil_nonempty_string($content_type) &&
|
||||||
|
preg_match('/;\s*charset=([^;]+)/', $content_type, $match)) {
|
||||||
$encoding = trim($match[1], "\"'");
|
$encoding = trim($match[1], "\"'");
|
||||||
try {
|
try {
|
||||||
$excerpt = phutil_utf8_convert($excerpt, 'UTF-8', $encoding);
|
$excerpt = phutil_utf8_convert($excerpt, 'UTF-8', $encoding);
|
||||||
|
|
Loading…
Reference in a new issue