Best practice forum (Archived)

Javascript Syntax Error from ' '

 
Simon Coggins
Re: Javascript Syntax Error from ' '
by Simon Coggins - Thursday, 15 September 2011, 9:29 PM
Group Totara

Here is the patch that fixed it:

diff --git a/lib/form/htmleditor.php b/lib/form/htmleditor.php
index a9c2a18..09dd230 100644
--- a/lib/form/htmleditor.php
+++ b/lib/form/htmleditor.php
@@ -75,7 +75,7 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
                                     $this->_options['width'],
                                     $this->_options['height'],
                                     $this->getName(),
-                                    preg_replace("/(\r\n|\n|\r)/", '
',$this->getValue()),
+                                    $this->getValue(),
                                     0, // unused anymore
                                     true,
                                     $this->getAttribute('id'));//.$script;
@@ -94,4 +94,4 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
         return $html . $this->_getPersistantData();
     } //end func getFrozenHtml
 }
-?>
\ No newline at end of file
+?>
diff --git a/lib/pear/HTML/QuickForm/textarea.php b/lib/pear/HTML/QuickForm/textarea.php
index 7aa0af2..358d870 100644
--- a/lib/pear/HTML/QuickForm/textarea.php
+++ b/lib/pear/HTML/QuickForm/textarea.php
@@ -190,7 +190,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
             return $this->_getTabs() .
                    '_getAttrString($this->_attributes) . '>' .
                    // because we wrap the form later we don't want the text indented
-                   preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value)) .
+                   htmlspecialchars($this->_value) .
                    '';
         }
     } //end func toHtml

Moodle was inserting the extra characters, which was then confusing TinyMCE.

Simon