Fix truncation of Unicode string query parameters in Benchmark
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 14 Jul 2023 08:28:50 +0000 (10:28 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 14 Jul 2023 08:28:50 +0000 (10:28 +0200)
This needs to use `mb_substr()`, as we checked UTF-8 validity before to use
`UNHEX()` with binary strings. Previously UTF-8 sequences might've been cut
short and the resulting invalid sequence cannot be JSON encoded, as JSON
requires strings to be valid UTF-8.

see https://www.woltlab.com/community/thread/298853-schwer-reproduzierbar-fehlermeldungen-beim-importieren-von-sprachdateien/

wcfsetup/install/files/lib/system/database/statement/PreparedStatement.class.php

index 3009e02ae1961d9fda1e7ebd5b1d58435b72cb38..f70211437c7fa2590f1f2c24d86aade75bf748a8 100644 (file)
@@ -115,7 +115,7 @@ class PreparedStatement
                                 );
                             }
 
-                            return "'" . \substr($parameter, 0, 100) . "'";
+                            return "'" . \mb_substr($parameter, 0, 100) . "'";
                         },
                         $this->query
                     ),