From ccf74a40dd3b43654d087ae9927ab074e2f481f3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 16 Oct 2020 09:18:50 -0700 Subject: [PATCH] Fix an issue where "phutil_utf8v()" could fatal when passed an integer Summary: See . I can't exactly reproduce the original issue, but when a query like "quack 1234" is tokenized, we end up calling "phutil_utf8v(1234)", where the argument is an integer. At least in recent versions of PHP, this fatals ("trying to access an offset of an integer"). Cast the argument first. Test Plan: Searched for "quack 1234" in Files. Before: fatal accessing offset of integer; after: correct results. Differential Revision: https://secure.phabricator.com/D21477 --- src/utils/utf8.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/utf8.php b/src/utils/utf8.php index f03663f3..c92ee533 100644 --- a/src/utils/utf8.php +++ b/src/utils/utf8.php @@ -426,6 +426,8 @@ function phutil_utf8_is_cjk($string) { * @return list A list of characters in the string. */ function phutil_utf8v($string, $byte_limit = null) { + $string = phutil_string_cast($string); + $res = array(); $len = strlen($string);