# HG changeset patch # User Christoph # Date 1266612556 -3600 # Node ID 8c52d3381a2e2989c7c7cb99b1678497751cfcca # Parent 6ce3cfa3624c680b339abe00e66747e67f6e101c Security-Fix: Variablen-Interpolation im TinyMCE entfernt Der Inhalt des WYSIWYG-Editors wird nicht mehr via HEREDOC-Syntax ausgelesen, sondern über eine neue REDAXO-Variable (REX_SQ_VALUE). Diese führt ein korrektes Escaping durch und ist für den Einsatz in Single Souted String (z.B. 'REX_SQ_VALUE[1]') gedacht. Parallel gibt es auch noch REX_DQ_VALUE für Strings in doppelten Anführungszeichen. diff -r 6ce3cfa3624c -r 8c52d3381a2e classes/class.rexvalue.inc.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/classes/class.rexvalue.inc.php Fri Feb 19 21:49:16 2010 +0100 @@ -0,0 +1,36 @@ +replaceVars($sql, $content, true); + $content = $this->replaceVars($sql, $content, false); + return $content; + } + + protected function replaceVars(&$sql, $content, $single) + { + $var = $single ? 'REX_SQ_VALUE' : 'REX_DQ_VALUE'; + $matches = $this->getVarParams($content, $var); + + foreach ($matches as $match) { + list ($param_str, $args) = $match; + list ($id, $args) = $this->extractArg('id', $args, 0); + + if ($id > 0 && $id < 21) { + $replace = $this->getValue($sql, 'value' . $id); + $replace = addcslashes($replace, $single ? "'\\" : "\"\\\$"); + $replace = $this->handleGlobalVarParams($var, $args, $replace); + $content = str_replace($var.'['.$param_str.']', $replace, $content); + } + } + + return $content; + } +} diff -r 6ce3cfa3624c -r 8c52d3381a2e config.inc.php --- a/config.inc.php Fri Feb 19 21:13:30 2010 +0100 +++ b/config.inc.php Fri Feb 19 21:49:16 2010 +0100 @@ -48,7 +48,12 @@ $rxa_tinymce['document_base'] = str_replace($_SERVER["DOCUMENT_ROOT"], '', str_replace("\\", "/", dirname(dirname(__FILE__)))); //echo $rxa_tinymce['fe_path']; +// Neue REDAXO-Variable bekanntmachen +if (!class_exists('rex_var_quoted_value')) { + require_once $REX['INCLUDE_PATH'].'/addons/'.$rxa_tinymce['name'].'/classes/class.rexvalue.inc.php'; + $REX['VARIABLES'][] = new rex_var_quoted_value(); +} // Konfigurationsvariablen, werden in pages/settings.inc.php geschrieben // ----------------------------------------------------------------------------- diff -r 6ce3cfa3624c -r 8c52d3381a2e examples/extended-input.txt --- a/examples/extended-input.txt Fri Feb 19 21:13:30 2010 +0100 +++ b/examples/extended-input.txt Fri Feb 19 21:49:16 2010 +0100 @@ -1,56 +1,50 @@ Fliesstext:
buttons1 = 'bold,italic,underline,strikethrough,sub,sup,|,forecolor,backcolor,styleselect,formatselect,|,charmap,cleanup,removeformat,|,preview,code,fullscreen'; + $tiny->buttons2 = 'cut,copy,paste,pastetext,pasteword,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,link,unlink,redaxoMedia,redaxoEmail,anchor,|,advhr,image,emotions,media,syntaxhighlighter'; + + // zusaetzliche Buttons für Undo/Redo, Tabellen und Template + $tiny->buttons3 = 'undo,redo,|,tablecontrols,visualaid,|,template,help'; + $tiny->buttons4 = ''; + + // Breite und Höhe des Editors + $tiny->width = 555; + $tiny->height = 350; + + // Valides XHTML generieren true/false + $tiny->validxhtml = false; + + // Hier können eigene Werte die Standardwerte überschreiben + // + // Achtung: + // bei einigen Parametern (z.B. Plugins) muss der Wert aus der + // Standardkonfiguration e r w e i t e r t werden + // Hier als Beispiel erweitert um die Plugins syntaxhighlighter, table, template + $mytinyconfig = <<configuration = $mytinyconfig; - // Buttons setzen (hier alle Buttons der Standardkonfiguration) - $tiny->buttons1 = 'bold,italic,underline,strikethrough,sub,sup,|,forecolor,backcolor,styleselect,formatselect,|,charmap,cleanup,removeformat,|,preview,code,fullscreen'; - $tiny->buttons2 = 'cut,copy,paste,pastetext,pasteword,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,link,unlink,redaxoMedia,redaxoEmail,anchor,|,advhr,image,emotions,media,syntaxhighlighter'; + // WYSIWYG-Content zuordnen + $tiny->content = trim('REX_SQ_VALUE[1]'); - // zusaetzliche Buttons fuer Undo/Redo, Tabellen und Template - $tiny->buttons3 = 'undo,redo,|,tablecontrols,visualaid,|,template,help'; - $tiny->buttons4 = ''; + // ID des REX_VALUES zuordnen + $tiny->id = 1; - // Breite und Hoehe des Editors - $tiny->width = 555; - $tiny->height = 350; - - // Valides XHTML generieren true/false - $tiny->validxhtml = false; - - // Hier koennen eigene Werte ueber die Standardwerte ueberlagert werden - // - // Achtung: - // bei einigen Parametern (z.B. Plugins) muss der Wert aus der - // Standardkonfiguration e r w e i t e r t werden - // Hier als Beispiel erweitert um die Plugins syntaxhighlighter, table, template -$mytinyconfig =<<configuration = $mytinyconfig; - - // WYSIWYG-Content zuordnen - $tiny->content = $wysiwigvalue; - - // Id des REX_VALUES zuordnen - $tiny->id = 1; - - // WYSIWYG-Editor anzeigen - $tiny->show(); + // WYSIWYG-Editor anzeigen + $tiny->show(); } -else -{ - echo rex_warning('Dieses Modul benötigt das "TinyMCE"-Addon!'); +else { + print rex_warning('Dieses Modul benötigt das "TinyMCE"-AddOn!'); } ?> \ No newline at end of file diff -r 6ce3cfa3624c -r 8c52d3381a2e examples/minimal-input.txt --- a/examples/minimal-input.txt Fri Feb 19 21:13:30 2010 +0100 +++ b/examples/minimal-input.txt Fri Feb 19 21:49:16 2010 +0100 @@ -1,26 +1,20 @@ Fliesstext:
content = trim('REX_SQ_VALUE[1]'); - // WYSIWYG-Content zuordnen - $tiny->content = $wysiwigvalue; + // Id des REX_VALUES zuordnen + $tiny->id = 1; - // Id des REX_VALUES zuordnen - $tiny->id = 1; - - // WYSIWYG-Editor anzeigen - $tiny->show(); + // WYSIWYG-Editor anzeigen + $tiny->show(); } -else -{ - echo rex_warning('Dieses Modul benötigt das "TinyMCE"-Addon!'); +else { + print rex_warning('Dieses Modul benötigt das "TinyMCE"-AddOn!'); } ?> \ No newline at end of file diff -r 6ce3cfa3624c -r 8c52d3381a2e examples/output.txt --- a/examples/output.txt Fri Feb 19 21:13:30 2010 +0100 +++ b/examples/output.txt Fri Feb 19 21:49:16 2010 +0100 @@ -1,15 +1,11 @@ '') - { - echo '
'; - echo $wysiwigvalue; - echo '
'; - } + if (!empty($wysiwigvalue)) { + print '
'; + print $wysiwigvalue; + print '
'; + } } ?> \ No newline at end of file diff -r 6ce3cfa3624c -r 8c52d3381a2e examples/simple-input.txt --- a/examples/simple-input.txt Fri Feb 19 21:13:30 2010 +0100 +++ b/examples/simple-input.txt Fri Feb 19 21:49:16 2010 +0100 @@ -1,5 +1,5 @@ Fliesstext:
- \ No newline at end of file