Commit 23300137 authored by Cédric Anne's avatar Cédric Anne
Browse files

Remove useless usage of Html::setRichTextContent()

parent 81ad398e
......@@ -32,6 +32,7 @@ The present file will list all changes made to the project; according to the
- `CommonDBTM::clone()`
- `CommonDBTM::prepareInputForClone()`
- `CommonDBTM::post_clone()`
- `Html::setRichTextContent()`
- `RuleImportComputer` class
- `RuleImportComputerCollection` class
......
......@@ -1170,12 +1170,7 @@ class Change extends CommonITILObject {
$content = Html::cleanPostForTextArea($content);
}
$content = Html::setRichTextContent(
$content_id,
$content,
$rand,
!$canupdate
);
$content = Toolbox::getHtmlToDisplay($content);
echo "<div id='content$rand_text'>";
if ($canupdate) {
......@@ -1191,11 +1186,11 @@ class Change extends CommonITILObject {
'required' => $tt->isMandatoryField('content'),
'rows' => $rows,
'enable_richtext' => true,
'value' => $content,
'value' => Html::entities_deep($content), // Re-encode entities for textarea
'uploads' => $uploads,
]);
} else {
echo Toolbox::getHtmlToDisplay($content);
echo $content;
}
echo "</div>";
......
......@@ -7164,9 +7164,8 @@ abstract class CommonITILObject extends CommonDBTM {
echo "</p>";
echo "<div class='rich_text_container'>";
$richtext = Html::setRichTextContent('', $content, '', true);
$richtext = Html::replaceImagesByGallery($richtext);
echo $richtext;
$content = Html::replaceImagesByGallery($content);
echo $content;
echo "</div>";
if (!empty($long_text)) {
......@@ -7446,9 +7445,9 @@ abstract class CommonITILObject extends CommonDBTM {
echo "</div>";
echo "<div class='rich_text_container'>";
$richtext = Html::setRichTextContent('', $this->fields['content'], '', true);
$richtext = Html::replaceImagesByGallery($richtext);
echo $richtext;
$content = Toolbox::getHtmlToDisplay($this->fields['content']);
$content = Html::replaceImagesByGallery($content);
echo $content;
echo "</div>";
echo "</div>"; // h_content ITILContent
......
......@@ -4023,9 +4023,13 @@ JS;
* @param boolean $readonly true will set editor in readonly mode
*
* @return $content
*
* @deprecated x.x.x
**/
static function setRichTextContent($name, $content, $rand, $readonly = false) {
Toolbox::deprecated();
// Init html editor (if name of textarea is provided)
if (!empty($name)) {
Html::initEditorSystem($name, $rand, true, $readonly);
......
......@@ -1634,12 +1634,7 @@ class Problem extends CommonITILObject {
$content = Html::cleanPostForTextArea($content);
}
$content = Html::setRichTextContent(
$content_id,
$content,
$rand,
!$canupdate
);
$content = Toolbox::getHtmlToDisplay($content);
echo "<div id='content$rand_text'>";
if ($canupdate) {
......@@ -1655,11 +1650,11 @@ class Problem extends CommonITILObject {
'required' => $tt->isMandatoryField('content'),
'rows' => $rows,
'enable_richtext' => true,
'value' => $content,
'value' => Html::entities_deep($content), // Re-encode entities for textarea
'uploads' => $uploads,
]);
} else {
echo Toolbox::getHtmlToDisplay($content);
echo $content;
}
echo "</div>";
......
......@@ -4027,7 +4027,6 @@ class Ticket extends CommonITILObject {
if (!$ticket_template) {
$content = Html::cleanPostForTextArea($options['content']);
}
$content = Html::setRichTextContent($content_id, $content, $rand);
echo "<div id='content$rand_text'>";
$uploads = [];
......@@ -4950,12 +4949,7 @@ class Ticket extends CommonITILObject {
$content = Html::cleanPostForTextArea($content);
}
$content = Html::setRichTextContent(
$content_id,
$content,
$rand,
!$canupdate
);
$content = Toolbox::getHtmlToDisplay($content);
echo "<div id='content$rand_text'>";
if ($canupdate || $can_requester) {
......@@ -4971,11 +4965,11 @@ class Ticket extends CommonITILObject {
'required' => $tt->isMandatoryField('content'),
'rows' => $rows,
'enable_richtext' => true,
'value' => $content,
'value' => Html::entities_deep($content), // Re-encode entities for textarea
'uploads' => $uploads,
]);
} else {
echo Toolbox::getHtmlToDisplay($content);
echo $content;
}
echo "</div>";
echo $tt->getEndHiddenFieldValue('content', $this);
......
......@@ -2999,11 +2999,17 @@ class Toolbox {
*/
public static function getHtmlToDisplay($content) {
$content = Toolbox::unclean_cross_side_scripting_deep(
Html::entity_decode_deep(
$content
)
$content
);
$content = nl2br(Html::clean($content, false, 1));
$content = Html::clean($content, false, 1);
// If content does not contain <br> or <p> html tag, use nl2br
// Required to correctly render linebreaks from "simple text mode" from GLPI prior to 9.4.0.
if (!preg_match('/<br\s?\/?>/', $content) && !preg_match('/<p>/', $content)) {
$content = nl2br($content);
}
return $content;
}
......
......@@ -3056,7 +3056,7 @@ class Ticket extends DbTestCase {
$instance = new \Ticket();
$instance->showForm('-1');
}
)->contains('src="data:image/png;base64,' . $base64Image . '"');
)->contains('src=&quot;data:image/png;base64,' . $base64Image . '&quot;');
}
public function testScreenshotConvertedIntoDocument() {
......@@ -3189,7 +3189,7 @@ class Ticket extends DbTestCase {
$instance->showForm('0');
$_SESSION['glpiactiveprofile']['tickettemplates_id'] = $session_tpl_id_back;
}
)->contains('src="data:image/png;base64,' . $base64Image . '"');
)->contains('src=&quot;data:image/png;base64,' . $base64Image . '&quot;');
}
......
Markdown is supported
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