From aa97890339d72225afea22d00cfcbd5af938b1c6 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 15 Jun 2020 11:25:18 +0100
Subject: [PATCH] =?UTF-8?q?Issue=20#3143618=20by=20Krzysztof=20Doma=C5=84s?=
 =?UTF-8?q?ki,=20daffie,=20longwave,=20Beakerboy:=20Replace=20space=20(U+0?=
 =?UTF-8?q?020)=20with=20No-Break=20Space=20(U+00A0)=20to=20minimize=20fal?=
 =?UTF-8?q?se=20positives?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 core/lib/Drupal/Core/Database/Connection.php           |  2 +-
 .../Drupal/Tests/Core/Database/ConnectionTest.php      | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index 3ca7de7b3aab..1ff55b14ece2 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -726,7 +726,7 @@ public function query($query, array $args = [], $options = []) {
         // semicolons should only be needed for special cases like defining a
         // function or stored procedure in SQL. Trim any trailing delimiter to
         // minimize false positives unless delimiter is allowed.
-        $trim_chars = "  \t\n\r\0\x0B";
+        $trim_chars = " \xA0\t\n\r\0\x0B";
         if (empty($options['allow_delimiter_in_query'])) {
           $trim_chars .= ';';
         }
diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
index e91ca645f76b..d5a2dec3163c 100644
--- a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
@@ -607,6 +607,16 @@ public function testQueryTrim($expected, $query, $options) {
    */
   public function provideQueriesToTrim() {
     return [
+      'remove_non_breaking_space' => [
+        'SELECT * FROM test',
+        "SELECT * FROM test\xA0",
+        [],
+      ],
+      'remove_ordinary_space' => [
+        'SELECT * FROM test',
+        'SELECT * FROM test ',
+        [],
+      ],
       'remove_semicolon' => [
         'SELECT * FROM test',
         'SELECT * FROM test;',
-- 
GitLab