Bug #34330

Encoding error in flexform sections if backend is not UTF-8

Added by Helmut Hummel about 1 year ago. Updated 8 months ago.

Status:Accepted Start date:2012-02-27
Priority:Must have Due date:
Assignee:- % Done:

0%

Category:TCEforms
Target version:-
TYPO3 Version:4.6 Complexity:
PHP Version:
Votes: 0

Description

#29067 introduced a regression, because the inline javascript was encoded twice. This was fixed in #32422 but this unfortunately introduced a regression for non UTF-8 backends.

The reason for the latter is that json_encode can only handle UTF-8 encoded strings.

Solution:
Encode the string to UTF-8 before handing it over to json_encode

34330.patch - Patch for Typo3 4.5.19 #34330 (1.4 kB) Ro!and , 2012-10-01 15:38


Related issues

related to Core - Bug #29067: Encoding UTF-8 in unescape function Resolved 2011-08-18
related to Core - Bug #32422: Encoding error in TCEforms inline JavaScript Resolved 2011-12-09
duplicated by Core - Bug #33377: Javascript error: URI malformed when adding new sections Closed 2012-01-23

History

Updated by Helmut Hummel about 1 year ago

  • Status changed from New to Accepted

Updated by Steffen Ritter about 1 year ago

  • Status changed from Accepted to Needs Feedback

is this still valid since non-utf-8 backends are not possible anymore?

Updated by Helmut Hummel about 1 year ago

  • Status changed from Needs Feedback to Accepted
  • TYPO3 Version changed from 4.7 to 4.6

It's still valid for TYPO3 <= 4.6

Updated by Ro!and 8 months ago

Here's my patch for the current 4.5.19. I copied the original File

class.t3lib_tceforms.php
to
class.t3lib_tceforms.php,org
first:

--- class.t3lib_tceforms.php,org 2012-10-01 15:13:07.000000000 +0200
+++ class.t3lib_tceforms.php 2012-10-01 15:19:56.000000000 +0200
@ -2800,7 +2800,12 @
$replace .= '.replace(/(tceforms-(datetime|date)field-)/g,"$1" + (new Date()).getTime())';
$onClickInsert = 'var ' . $var . ' = "' . 'idx"+(new Date()).getTime();';
// Do not replace $isTagPrefix in setActionStatus() because it needs section id!
- $onClickInsert .= 'new Insertion.Bottom($("' . $idTagPrefix . '"), ' . json_encode($newElementTemplate) . '.' . $replace . '); setActionStatus("' . $idTagPrefix . '");';
+ if ( (strtolower($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']) ===
+'utf-8') )
+ $newElementTemplatePatched = $newElementTemplate;
+ else
+ $newElementTemplatePatched = utf8_encode( $newElementTemplate );
+ $onClickInsert .= 'new Insertion.Bottom($("' . $idTagPrefix . '"), ' . json_encode( $newElementTemplatePatched ) . '.' . $replace . '); setActionStatus("' . $idTagPrefix . '");';
$onClickInsert .= 'eval(unescape("' . rawurlencode(implode(';', $this->additionalJS_post)) . '").' . $replace . ');';
$onClickInsert .= 'TBE_EDITOR.addActionChecks("submit", unescape("' . rawurlencode(implode(';', $this->additionalJS_submit)) . '").' . $replace . ');';
$onClickInsert .= 'TYPO3.TCEFORMS.update();';

Please note: This patch should not be used for TYPO3 Version >= 4.6, since this will probably fail:

if ( (strtolower($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']) === 'utf-8') )

Also available in: Atom PDF