Commit f3ba90d6 authored by Benni Mack's avatar Benni Mack
Browse files

[TASK] Deprecate unused GeneralUtility methods

Resolves: #68098
Releases: master
Change-Id: Ice78388b6e39886bb3f2be13701d4b85f01f3967
Reviewed-on: http://review.typo3.org/41157


Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 818fc3ec
......@@ -161,7 +161,7 @@ class EditFileController {
// Edit textarea:
$code .= '
<div id="c-edit">
<textarea rows="30" name="file[editfile][0][data]" wrap="off" ' . $this->doc->formWidth(48, TRUE, 'width:98%;height:80%') . ' class="text-monospace t3js-enable-tab">' . GeneralUtility::formatForTextarea($fileContent) . '</textarea>
<textarea rows="30" name="file[editfile][0][data]" wrap="off" ' . $this->doc->formWidth(48, TRUE, 'width:98%;height:80%') . ' class="text-monospace t3js-enable-tab">' . htmlspecialchars($fileContent) . '</textarea>
<input type="hidden" name="file[editfile][0][target]" value="' . $this->fileObject->getUid() . '" />
<input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) . '" />
' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction') . '
......
......@@ -315,7 +315,7 @@ class TableController extends AbstractWizardController {
$cells[] = '<input class="form-control" type="text"' . $this->doc->formWidth(20) . ' name="TABLE[c][' . ($k + 1) * 2 . '][' . ($a + 1) * 2 . ']" value="' . htmlspecialchars($cellContent) . '" />';
} else {
$cellContent = preg_replace('/<br[ ]?[\\/]?>/i', LF, $cellContent);
$cells[] = '<textarea class="form-control" ' . $this->doc->formWidth(20) . ' rows="6" name="TABLE[c][' . ($k + 1) * 2 . '][' . ($a + 1) * 2 . ']">' . GeneralUtility::formatForTextarea($cellContent) . '</textarea>';
$cells[] = '<textarea class="form-control" ' . $this->doc->formWidth(20) . ' rows="6" name="TABLE[c][' . ($k + 1) * 2 . '][' . ($a + 1) * 2 . ']">' . htmlspecialchars($cellContent) . '</textarea>';
}
// Increment counter:
$a++;
......
......@@ -174,7 +174,7 @@ class TextElement extends AbstractFormElement {
. $attributeString
. $placeholderAttribute
. $parameterArray['onFocus']
. '>' . GeneralUtility::formatForTextarea($parameterArray['itemFormElValue']) . '</textarea>';
. '>' . htmlspecialchars($parameterArray['itemFormElValue']) . '</textarea>';
// Wrap a wizard around the item?
$html = $this->renderWizards(
......
......@@ -216,7 +216,7 @@ class FormContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConten
}
$noValueInsert = isset($conf['noValueInsert.']) ? $this->cObj->stdWrap($conf['noValueInsert'], $conf['noValueInsert.']) : $conf['noValueInsert'];
$default = $this->getFieldDefaultValue($noValueInsert, $confData['fieldname'], str_replace('\\n', LF, trim($parts[2])));
$fieldCode = sprintf('<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>', $confData['fieldname'], $elementIdAttribute, $cols, $rows, $wrap, $addParams, GeneralUtility::formatForTextarea($default));
$fieldCode = sprintf('<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>', $confData['fieldname'], $elementIdAttribute, $cols, $rows, $wrap, $addParams, htmlspecialchars($default));
break;
case 'input':
......
......@@ -450,7 +450,7 @@ class FormsController extends \TYPO3\CMS\Backend\Controller\Wizard\AbstractWizar
}
// Default data
if ($confData['type'] == 'select' || $confData['type'] == 'radio') {
$temp_cells[$this->getLanguageService()->getLL('forms_options')] = '<textarea ' . $this->doc->formWidth(15) . ' rows="4" name="FORMCFG[c][' . ($k + 1) * 2 . '][options]" title="' . $this->getLanguageService()->getLL('forms_options', TRUE) . '">' . GeneralUtility::formatForTextarea($confData['default']) . '</textarea>';
$temp_cells[$this->getLanguageService()->getLL('forms_options')] = '<textarea ' . $this->doc->formWidth(15) . ' rows="4" name="FORMCFG[c][' . ($k + 1) * 2 . '][options]" title="' . $this->getLanguageService()->getLL('forms_options', TRUE) . '">' . htmlspecialchars($confData['default']) . '</textarea>';
} elseif ($confData['type'] == 'check') {
$temp_cells[$this->getLanguageService()->getLL('forms_checked')] = '<input type="checkbox" name="FORMCFG[c][' . ($k + 1) * 2 . '][default]" value="1"' . (trim($confData['default']) ? ' checked="checked"' : '') . ' title="' . $this->getLanguageService()->getLL('forms_checked', TRUE) . '" />';
} elseif ($confData['type'] && $confData['type'] != 'file') {
......
......@@ -411,7 +411,7 @@ class QueryView {
$rowArr[] = $this->csvValues($row, ',', '"', $GLOBALS['TCA'][$table], $table);
}
if (!empty($rowArr)) {
$out .= '<textarea name="whatever" rows="20" wrap="off"' . $GLOBALS['SOBE']->doc->formWidth($this->formW) . ' class="text-monospace">' . GeneralUtility::formatForTextarea(implode(LF, $rowArr)) . '</textarea>';
$out .= '<textarea name="whatever" rows="20" wrap="off"' . $GLOBALS['SOBE']->doc->formWidth($this->formW) . ' class="text-monospace">' . htmlspecialchars(implode(LF, $rowArr)) . '</textarea>';
if (!$this->noDownloadB) {
$out .= '<br><input class="btn btn-default" type="submit" name="download_file" value="Click to download file" onClick="window.location.href=\'' . $this->downloadScript . '\';">';
}
......
......@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\TypoScript\Parser;
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
......@@ -1249,7 +1250,7 @@ class TypoScriptParser {
$lineC .= $this->highLightStyles['error'][0] . '<strong> - ERROR:</strong> ' . htmlspecialchars(implode(';', $errA[$rawP])) . $this->highLightStyles['error'][1];
}
if ($highlightBlockMode && $this->highLightData_bracelevel[$rawP]) {
$lineC = str_pad('', $this->highLightData_bracelevel[$rawP] * 2, ' ', STR_PAD_LEFT) . '<span style="' . $this->highLightBlockStyles . ($this->highLightBlockStyles_basecolor ? 'background-color: ' . GeneralUtility::modifyHTMLColorAll($this->highLightBlockStyles_basecolor, -$this->highLightData_bracelevel[$rawP] * 16) : '') . '">' . ($lineC !== '' ? $lineC : '&nbsp;') . '</span>';
$lineC = str_pad('', $this->highLightData_bracelevel[$rawP] * 2, ' ', STR_PAD_LEFT) . '<span style="' . $this->highLightBlockStyles . ($this->highLightBlockStyles_basecolor ? 'background-color: ' . $this->modifyHTMLColorAll($this->highLightBlockStyles_basecolor, -$this->highLightData_bracelevel[$rawP] * 16) : '') . '">' . ($lineC !== '' ? $lineC : '&nbsp;') . '</span>';
}
if (is_array($lineNumDat)) {
$lineNum = $rawP + $lineNumDat[0];
......@@ -1270,4 +1271,34 @@ class TypoScriptParser {
return isset($GLOBALS['TT']) ? $GLOBALS['TT'] : NULL;
}
/**
* Modifies a HTML Hex color by adding/subtracting $R,$G and $B integers
*
* @param string $color A hexadecimal color code, #xxxxxx
* @param int $R Offset value 0-255
* @param int $G Offset value 0-255
* @param int $B Offset value 0-255
* @return string A hexadecimal color code, #xxxxxx, modified according to input vars
* @see modifyHTMLColorAll()
*/
protected function modifyHTMLColor($color, $R, $G, $B) {
// This takes a hex-color (# included!) and adds $R, $G and $B to the HTML-color (format: #xxxxxx) and returns the new color
$nR = MathUtility::forceIntegerInRange(hexdec(substr($color, 1, 2)) + $R, 0, 255);
$nG = MathUtility::forceIntegerInRange(hexdec(substr($color, 3, 2)) + $G, 0, 255);
$nB = MathUtility::forceIntegerInRange(hexdec(substr($color, 5, 2)) + $B, 0, 255);
return '#' . substr(('0' . dechex($nR)), -2) . substr(('0' . dechex($nG)), -2) . substr(('0' . dechex($nB)), -2);
}
/**
* Modifies a HTML Hex color by adding/subtracting $all integer from all R/G/B channels
*
* @param string $color A hexadecimal color code, #xxxxxx
* @param int $all Offset value 0-255 for all three channels.
* @return string A hexadecimal color code, #xxxxxx, modified according to input vars
* @see modifyHTMLColor()
*/
protected function modifyHTMLColorAll($color, $all) {
return $this->modifyHTMLColor($color, $all, $all, $all);
}
}
......@@ -872,8 +872,10 @@ class GeneralUtility {
* @param int $B Offset value 0-255
* @return string A hexadecimal color code, #xxxxxx, modified according to input vars
* @see modifyHTMLColorAll()
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
static public function modifyHTMLColor($color, $R, $G, $B) {
self::logDeprecatedFunction();
// This takes a hex-color (# included!) and adds $R, $G and $B to the HTML-color (format: #xxxxxx) and returns the new color
$nR = MathUtility::forceIntegerInRange(hexdec(substr($color, 1, 2)) + $R, 0, 255);
$nG = MathUtility::forceIntegerInRange(hexdec(substr($color, 3, 2)) + $G, 0, 255);
......@@ -888,8 +890,10 @@ class GeneralUtility {
* @param int $all Offset value 0-255 for all three channels.
* @return string A hexadecimal color code, #xxxxxx, modified according to input vars
* @see modifyHTMLColor()
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
static public function modifyHTMLColorAll($color, $all) {
self::logDeprecatedFunction();
return self::modifyHTMLColor($color, $all, $all, $all);
}
......@@ -1082,8 +1086,10 @@ class GeneralUtility {
* by || with the rest in this function.
*
* @return bool TRUE if mail() does not accept recipient name
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
static public function isBrokenEmailEnvironment() {
self::logDeprecatedFunction();
return TYPO3_OS == 'WIN' || FALSE !== strpos(ini_get('sendmail_path'), 'mini_sendmail');
}
......@@ -1092,8 +1098,10 @@ class GeneralUtility {
*
* @param string $address Address to adjust
* @return string Adjusted address
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
static public function normalizeMailAddress($address) {
self::logDeprecatedFunction();
if (self::isBrokenEmailEnvironment() && FALSE !== ($pos1 = strrpos($address, '<'))) {
$pos2 = strpos($address, '>', $pos1);
$address = substr($address, $pos1 + 1, ($pos2 ? $pos2 : strlen($address)) - $pos1 - 1);
......@@ -1108,8 +1116,10 @@ class GeneralUtility {
*
* @param string $content Input string to be formatted.
* @return string Formatted for <textarea>-tags
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
*/
static public function formatForTextarea($content) {
self::logDeprecatedFunction();
return LF . htmlspecialchars($content);
}
......@@ -3152,8 +3162,10 @@ Connection: close
* Returns the HOST+DIR-PATH of the current script (The URL, but without 'http://' and without script-filename)
*
* @return string
* @deprecated since TYPO3 CMS 7, will be removed in CMS 8, use GeneralUtility::getIndpEnv* instead
*/
static public function getThisUrl() {
self::logDeprecatedFunction();
// Url of this script
$p = parse_url(self::getIndpEnv('TYPO3_REQUEST_SCRIPT'));
$dir = self::dirname($p['path']) . '/';
......@@ -5131,8 +5143,10 @@ Connection: close
* Ends and cleans all output buffers
*
* @return void
* @deprecated since TYPO3 CMS 7, will be removed in CMS 8, use ob_* functions directly or self::flushOutputBuffers
*/
static public function cleanOutputBuffers() {
self::logDeprecatedFunction();
while (ob_end_clean()) {
}
......
======================================================
Deprecation: #68098 - Deprecate GeneralUtility methods
======================================================
Description
===========
The following methods within GeneralUtility have been marked as deprecated and will be removed in TYPO3 CMS v8.
.. code-block:: php
GeneralUtility::modifyHTMLColor()
GeneralUtility::modifyHTMLColorAll()
GeneralUtility::isBrokenEmailEnvironment()
GeneralUtility::normalizeMailAddress()
GeneralUtility::formatForTextarea()
GeneralUtility::getThisUrl()
GeneralUtility::cleanOutputBuffers()
The functionality ``formatForTextarea()`` was used in the older days to actually support IE4 and Netscape 3 properly
and can now safely be exchanged by ``htmlspecialchars()``.
Impact
======
All extensions using these methods directly will throw a deprecation message.
Affected Installations
======================
Installations with extensions that use the methods above handling.
Migration
=========
Use corresponding functionality from ``getIndpEnv()`` instead of ``getThisUrl()``.
For the other methods, you can re-implement the functionality yourself in your extension where needed.
......@@ -808,7 +808,7 @@ class ImportExportController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
' . $this->lang->getLL('makesavefo_description', TRUE) . ' <br/>
<input type="text" name="tx_impexp[meta][description]" value="' . htmlspecialchars($inData['meta']['description']) . '"' . $this->doc->formWidth(30) . ' /><br/>
' . $this->lang->getLL('makesavefo_notes', TRUE) . ' <br/>
<textarea name="tx_impexp[meta][notes]"' . $this->doc->formWidth(30, 1) . '>' . GeneralUtility::formatForTextarea($inData['meta']['notes']) . '</textarea><br/>
<textarea name="tx_impexp[meta][notes]"' . $this->doc->formWidth(30, 1) . '>' . htmlspecialchars($inData['meta']['notes']) . '</textarea><br/>
' . (!empty($thumbnailFiles) ? '
' . $this->lang->getLL('makesavefo_thumbnail', TRUE) . '<br/>
' . $this->renderSelectBox('tx_impexp[meta][thumbnail]', $inData['meta']['thumbnail'], $thumbnailFiles) : '') . '<br/>
......
......@@ -345,7 +345,7 @@ class RichTextElement extends AbstractFormElement {
$result[] = '</div>';
$result[] = '<div id="editorWrap' . $this->domIdentifier . '" class="editorWrap" style="visibility: hidden; width:' . $editorWrapWidth . '; height:100%;">';
$result[] = '<textarea id="RTEarea' . $this->domIdentifier . '" name="' . htmlspecialchars($itemFormElementName) . '" rows="0" cols="0" style="' . htmlspecialchars($rteDivStyle) . '">';
$result[] = GeneralUtility::formatForTextarea($value);
$result[] = htmlspecialchars($value);
$result[] = '</textarea>';
$result[] = '</div>';
......
......@@ -245,7 +245,7 @@ class TypoScriptTemplateInformationModuleFunctionController extends AbstractFunc
unset($e);
}
if (isset($e['constants'])) {
$outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab"' . $this->pObj->doc->formWidth(48, TRUE, 'width:98%;height:70%') . ' class="text-monospace">' . GeneralUtility::formatForTextarea($tplRow['constants']) . '</textarea>';
$outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab"' . $this->pObj->doc->formWidth(48, TRUE, 'width:98%;height:70%') . ' class="text-monospace">' . htmlspecialchars($tplRow['constants']) . '</textarea>';
$outCode .= '<input type="hidden" name="e[constants]" value="1">';
// Display "Include TypoScript file content?" checkbox
$outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[constants]=1', 'id="checkIncludeTypoScriptFileContent"');
......@@ -255,7 +255,7 @@ class TypoScriptTemplateInformationModuleFunctionController extends AbstractFunc
$theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
}
if (isset($e['config'])) {
$outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab"' . $this->pObj->doc->formWidth(48, TRUE, 'width:98%;height:70%') . ' class="text-monospace">' . GeneralUtility::formatForTextarea($tplRow['config']) . '</textarea>';
$outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="text-monospace enable-tab"' . $this->pObj->doc->formWidth(48, TRUE, 'width:98%;height:70%') . ' class="text-monospace">' . htmlspecialchars($tplRow['config']) . '</textarea>';
$outCode .= '<input type="hidden" name="e[config]" value="1">';
// Display "Include TypoScript file content?" checkbox
$outCode .= '<div class="checkbox"><label for="checkIncludeTypoScriptFileContent">' . BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[config]=1', 'id="checkIncludeTypoScriptFileContent"');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment