From 6f71a3b82d7018dff437cdd316f3eb851fd3713c 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/Common/Quoter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Common/Quoter.php b/src/Common/Quoter.php index 2ef6e29..64a5b0d 100644 --- a/src/Common/Quoter.php +++ b/src/Common/Quoter.php @@ -206,7 +206,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"; }