diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index c790dafa571b0d6c943f58dcee3dc71193cb9fc1..b0d7d1ff82add34eb8d26bf0e03329de6a0dea3a 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -3277,8 +3277,13 @@ class ContentObjectRenderer
     }
 
     /**
-     * Implements the "insertData" property of stdWrap meaning that if strings matching {...} is found in the input string they will be substituted with the return value from getData (datatype) which is passed the content of the curly braces.
-     * Example: If input string is "This is the page title: {page:title}" then the part, '{page:title}', will be substituted with the current pages title field value.
+     * Implements the "insertData" property of stdWrap meaning that if strings matching {...} is found in the input string they
+     * will be substituted with the return value from getData (datatype) which is passed the content of the curly braces.
+     * If the content inside the curly braces starts with a hash sign {#...} it is a field name that must be quoted by Doctrine
+     * DBAL and is skipped here for later processing.
+     *
+     * Example: If input string is "This is the page title: {page:title}" then the part, '{page:title}', will be substituted with
+     * the current pages title field value.
      *
      * @param string $str Input value
      * @return string Processed input value
@@ -3295,6 +3300,12 @@ class ContentObjectRenderer
                 $len = strcspn(substr($str, $pointer), '{');
                 $newVal .= substr($str, $pointer, $len);
                 $inside = true;
+                if (substr($str, $pointer + $len + 1, 1) === '#') {
+                    $len2 = strcspn(substr($str, $pointer + $len), '}');
+                    $newVal .= substr($str, $pointer + $len, $len2);
+                    $len += $len2;
+                    $inside = false;
+                }
             } else {
                 $len = strcspn(substr($str, $pointer), '}') + 1;
                 $newVal .= $this->getData(substr($str, $pointer + 1, $len - 2), $this->data);
diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
index ec54c04ff890b1845aa57223409be338a4691262..b8ed108e2b3abd720d25ba9cada3dbd939d120e2 100644
--- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
+++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
@@ -5628,6 +5628,33 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
             $subject->stdWrap_insertData($content, $conf));
     }
 
+    /**
+     * Data provider for stdWrap_insertData
+     *
+     * @return array [$expect, $content]
+     */
+    public function stdWrap_insertDataProvider()
+    {
+        return [
+            'empty' => ['', ''],
+            'notFoundData' => ['any=1', 'any{$string}=1'],
+            'queryParameter' => ['any{#string}=1', 'any{#string}=1'],
+        ];
+    }
+
+    /**
+     * Check that stdWrap_insertData works properly with given input.
+     *
+     * @test
+     * @dataProvider stdWrap_insertDataProvider
+     * @param int $expect The expected output.
+     * @param string $content The given input.
+     */
+    public function stdWrap_insertDataAndInputExamples($expect, $content)
+    {
+        $this->assertSame($expect, $this->subject->stdWrap_insertData($content));
+    }
+
     /**
      * Data provider for stdWrap_intval
      *