Skip to content
Permalink
Browse files

fixed re-editing plaintext; #updates #998

  • Loading branch information...
following5 committed Aug 24, 2017
1 parent 27fc7f8 commit 9621fb76e14bd661ba6571cb7038bfa7878abef5
Showing with 21 additions and 15 deletions.
  1. +4 −3 htdocs/editdesc.php
  2. +3 −3 htdocs/editlog.php
  3. +7 −3 htdocs/lib2/edithelper.inc.php
  4. +2 −2 htdocs/log.php
  5. +3 −2 htdocs/newcache.php
  6. +2 −2 htdocs/newdesc.php
@@ -144,7 +144,7 @@
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
}
$desc = processEditorInput($oldDescMode, $descMode, $desc);
$desc = processEditorInput($oldDescMode, $descMode, $desc, $representDesc);
if (isset($_POST['submitform'])) { // Ocprop
// prüfen, ob sprache nicht schon vorhanden
@@ -221,15 +221,16 @@
$oldDescMode = ($desc_html == 0 ? 0 : ($desc_htmledit ? 3 : 2));
if ($oldDescMode == 0) {
$desc = processEditorInput($oldDescMode, $descMode, $desc_record['desc']);
$desc = processEditorInput($oldDescMode, $descMode, $desc_record['desc'], $representDesc);
} else {
$desc = $desc_record['desc'];
$representDesc = $desc;
}
}
//here we only set up the template variables
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'), true);
tpl_set_var('desc', htmlspecialchars($representDesc, ENT_COMPAT, 'UTF-8'), true);
tpl_set_var('descMode', $descMode);
tpl_set_var('htmlnotice', $descMode == 2 ? $htmlnotice : '');
@@ -225,7 +225,7 @@
$log_text = iconv("ISO-8859-1", "UTF-8", $log_text);
}
$log_text = processEditorInput($oldDescMode, $descMode, $log_text);
$log_text = processEditorInput($oldDescMode, $descMode, $log_text, $represent_text);
//validate date
$date_ok = false;
@@ -442,9 +442,9 @@
tpl_set_var('date_message', !$date_ok ? $date_message : '');
if ($descMode != 1) {
tpl_set_var('logtext', htmlspecialchars($log_text, ENT_COMPAT, 'UTF-8'), true);
tpl_set_var('logtext', htmlspecialchars($represent_text, ENT_COMPAT, 'UTF-8'), true);
} else {
tpl_set_var('logtext', $log_text);
tpl_set_var('logtext', $represent_text);
}
// Text / normal HTML / HTML editor
@@ -27,7 +27,7 @@
* @param $text
* @return mixed|string
*/
function processEditorInput($oldDescMode, $descMode, $text)
function processEditorInput($oldDescMode, $descMode, $text, &$representText)
{
global $opt, $smiley;
@@ -37,20 +37,24 @@ function processEditorInput($oldDescMode, $descMode, $text)
$text = nl2br(htmlspecialchars($text));
// .. and smilies
$text = str_replace($smiley['text'], $smiley['spaced_image'], $text);
$representText = $text;
} else {
// save HTML input => verify / tidy / filter;
// also implemented in okapi/services/logs/submit.php
$purifier = new OcHTMLPurifier($opt);
$text = $purifier->purify($text);
$representText = $text;
}
} else {
if ($oldDescMode == 1) {
// save plain text input => convert to HTML;
// keep plain text for re-presenting to the user
$representText = $text;
// convert to HTML for storing to database
// also implemented in okapi/services/logs/submit.php
$text = nl2br(htmlspecialchars($text, ENT_COMPAT, 'UTF-8'));
} else {
// mode switch from HTML editor to plain text, or decode HTML-encoded plain text
$text = html2plaintext($text, $oldDescMode = 0, 0);
$representText = html2plaintext($text, $oldDescMode = 0, 0);
}
}
@@ -203,7 +203,7 @@
$tpl->add_header_javascript(editorJsPath());
// check and prepare log text
$logText = processEditorInput($oldDescMode, $descMode, $logText);
$logText = processEditorInput($oldDescMode, $descMode, $logText, $representLogText);
// validate date
if (is_numeric($logDateMonth)
@@ -368,7 +368,7 @@
$tpl->assign('listing_outdated', $listingOutdated);
$tpl->assign('condition_history', $cache->getConditionHistory());
// log text
$tpl->assign('logtext', $logText);
$tpl->assign('logtext', $representLogText);
// text, <html> or editor
$tpl->assign('descMode', $descMode);
// logtypes
@@ -147,12 +147,13 @@
//desc
if (isset($_POST['desc'])) {
$desc = trim(processEditorInput($oldDescMode, $descMode, $_POST['desc']));
$desc = trim(processEditorInput($oldDescMode, $descMode, $_POST['desc'], $representDesc));
} else {
$desc = '';
$representDesc = '';
}
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('desc', htmlspecialchars($representDesc, ENT_COMPAT, 'UTF-8'));
$headers = tpl_get_var('htmlheaders') . "\n";
if ($descMode == 3) {
@@ -82,7 +82,7 @@
}
// Filter Input
$desc = processEditorInput($oldDescMode, $descMode, $desc);
$desc = processEditorInput($oldDescMode, $descMode, $desc, $representDesc);
$desc_lang_exists = false;
@@ -218,7 +218,7 @@
tpl_set_var('show_all_langs', $show_all_langs);
tpl_set_var('show_all_langs_submit', ($show_all_langs == 0) ? $show_all_langs_submit : '');
tpl_set_var('short_desc', htmlspecialchars($short_desc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('desc', htmlspecialchars($representDesc, ENT_COMPAT, 'UTF-8'));
tpl_set_var('hints', htmlspecialchars($hints, ENT_COMPAT, 'UTF-8'));
// Text / normal HTML / HTML editor

0 comments on commit 9621fb7

Please sign in to comment.
You can’t perform that action at this time.