From e693e166904aacdbe3a50978843246623ba3eb3a Mon Sep 17 00:00:00 2001 From: Elizabeth M Smith Date: Thu, 20 Apr 2023 15:41:14 -0400 Subject: [PATCH] [BUG] Fix bad use of strripos It is 100% valid for strripos to return 0 we want quotes in that case for the AS blah NEVER EVER if a strripos, always explicitly check for false!! This was breaking jsonb text returns with mixed case aliases Select "pt"."name"->>'en_US' AS "myDescription" from mytable pt is what we want to end up with The replaceNamesAndAliasIn was getting ' AS myDescription' and not properly escaping it because the strripos was returning 0 --- src/Quoter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Quoter.php b/src/Quoter.php index d745098..b24e187 100644 --- a/src/Quoter.php +++ b/src/Quoter.php @@ -223,7 +223,7 @@ protected function replaceNamesAndAliasIn($val) { $quoted = $this->replaceNamesIn($val); $pos = strripos($quoted, ' AS '); - if ($pos) { + if ($pos !== false) { $alias = $this->replaceName(substr($quoted, $pos + 4)); $quoted = substr($quoted, 0, $pos) . " AS $alias"; }