Fixed bug #13104: SQL parser cannot parse escaped single quote in INSERT statement
authorXavier Perseguers <typo3@perseguers.ch>
Mon, 28 Dec 2009 00:40:06 +0000 (00:40 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Mon, 28 Dec 2009 00:40:06 +0000 (00:40 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@28103 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/ChangeLog
typo3/sysext/dbal/class.ux_t3lib_sqlparser.php
typo3/sysext/dbal/tests/sqlparser_general_testcase.php

index 7337c78..a2f1c8c 100644 (file)
@@ -1,3 +1,7 @@
+2009-12-28  Xavier Perseguers  <typo3@perseguers.ch>
+
+       * Fixed bug #13104: SQL parser cannot parse escaped single quote in INSERT statement
+
 2009-12-27  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Updated documentation: now using new documentation template
 2009-12-27  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Updated documentation: now using new documentation template
index 4f1739a..5441255 100644 (file)
@@ -59,6 +59,18 @@ class ux_t3lib_sqlparser extends t3lib_sqlparser {
                        // TODO: Handle SQL hints in comments according to current DBMS
                return parent::compileFieldList($selectFields, FALSE);
        }
                        // TODO: Handle SQL hints in comments according to current DBMS
                return parent::compileFieldList($selectFields, FALSE);
        }
+
+       /**
+        * Add slashes function used for compiling queries
+        * This method overrides the method from t3lib_sqlparser because
+        * the input string is already properly escaped.
+        *
+        * @param       string          Input string
+        * @return      string          Output string
+        */
+       protected function compileAddslashes($str) {
+               return $str;
+       }
        
        /*************************
         *
        
        /*************************
         *
index f797e1c..8c92060 100644 (file)
@@ -117,11 +117,36 @@ class sqlparser_general_testcase extends BaseTestCase {
 
        /**
         * @test
 
        /**
         * @test
+        * @see http://bugs.typo3.org/view.php?id=13104
         */
        public function canGetStringValue() {
         */
        public function canGetStringValue() {
-               $parseString = '"some owner\\\' string"';
+               $parseString = '"some owner\\\'s string"';
                $value = $this->fixture->_callRef('getValue', $parseString);
                $value = $this->fixture->_callRef('getValue', $parseString);
-               $expected = array('some owner\' string', '"');
+               $expected = array('some owner\'s string', '"');
+
+               $this->assertEquals($expected, $value);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13104
+        */
+       public function canGetStringValueWithSingleQuote() {
+               $parseString = "'some owner\'s string'";
+               $value = $this->fixture->_callRef('getValue', $parseString);
+               $expected = array('some owner\'s string', "'");
+
+               $this->assertEquals($expected, $value);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=13104
+        */
+       public function canGetStringValueWithDoubleQuote() {
+               $parseString = '"the \"owner\" is here"';
+               $value = $this->fixture->_callRef('getValue', $parseString);
+               $expected = array('the "owner" is here', '"');
 
                $this->assertEquals($expected, $value);
        }
 
                $this->assertEquals($expected, $value);
        }