[BUGFIX] File upload in RTE-Link-Editor throws 500 error 50/20850/7
authorPhilipp Gampe <philipp.gampe@typo3.org>
Thu, 16 May 2013 18:42:49 +0000 (20:42 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 7 Jul 2013 00:01:13 +0000 (02:01 +0200)
When you want to add a link in the RTE-Editor, you can upload files in
the "File" tab. When you select a file and want to upload it, the
reloaded content in the create-link-overlay will throw an error.

The method is feed with a translation of "none - new file".

Bypass the file or folder lookup if we do not have an integer id
and print the message instead.

Resolves: #48219
Releases: 6.2, 6.1, 6.0
Change-Id: I9e1e6bc84b21fb04608841515ac414eec8c04130
Reviewed-on: https://review.typo3.org/20850
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Build/UnitTests.xml
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
typo3/sysext/recordlist/Tests/Unit/Browser/ElementBrowserTest.php [new file with mode: 0644]

index 4bfdec7..847f0da 100644 (file)
@@ -58,6 +58,9 @@
                <testsuite name="EXT:lowlevel tests">
                        <directory>../../../../typo3/sysext/lowlevel/Tests/Unit/</directory>
                </testsuite>
+               <testsuite name="EXT:recordlist tests">
+                       <directory>../../../../typo3/sysext/recordlist/Tests/Unit/</directory>
+               </testsuite>
                <testsuite name="EXT:reports tests">
                        <directory>../../../../typo3/sysext/reports/Tests/Unit/</directory>
                </testsuite>
@@ -72,4 +75,4 @@
                </testsuite>
        </testsuites>
 
-</phpunit>
\ No newline at end of file
+</phpunit>
index 9ef5315..3d6cd97 100644 (file)
@@ -1973,7 +1973,7 @@ class ElementBrowser {
         */
        public function printCurrentUrl($str) {
                // Output the folder or file identifier, when working with files
-               if ($str && $this->act == 'file' || $this->act == 'folder') {
+               if (isset($str) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($str) && ($this->act === 'file' || $this->act === 'folder')) {
                        try {
                                $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($str);
                                if (is_object($fileObject)) {
diff --git a/typo3/sysext/recordlist/Tests/Unit/Browser/ElementBrowserTest.php b/typo3/sysext/recordlist/Tests/Unit/Browser/ElementBrowserTest.php
new file mode 100644 (file)
index 0000000..3e77bee
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+namespace TYPO3\CMS\Recordlist\Tests\Unit\Browser;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2013 Philipp Gampe <philipp.gampe@typo3.org>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Test case
+ */
+class ElementBrowserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+
+       /**
+        * @test
+        */
+       public function printCurrentUrlWithAnyTextReturnsThatText() {
+               $fixture = new \TYPO3\CMS\Recordlist\Browser\ElementBrowser();
+               $fixture->act = 'file';
+               $result = $fixture->printCurrentUrl('Teststring');
+               $this->assertContains('Teststring', $result);
+       }
+}
+?>
\ No newline at end of file