Merge "Fix malformed UTF-8 going to query profiler"
[lhc/web/wiklou.git] / includes / content / JavaScriptContent.php
index 5221168..0991f07 100644 (file)
  * @ingroup Content
  */
 class JavaScriptContent extends TextContent {
+
+       /**
+        * @param string $text JavaScript code.
+        */
        public function __construct( $text ) {
                parent::__construct( $text, CONTENT_MODEL_JAVASCRIPT );
        }
@@ -42,25 +46,30 @@ class JavaScriptContent extends TextContent {
         * @param Title $title
         * @param User $user
         * @param ParserOptions $popts
-        * @return Content
+        *
+        * @return JavaScriptContent
         */
        public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
                global $wgParser;
-               // @todo: make pre-save transformation optional for script pages
+               // @todo Make pre-save transformation optional for script pages
                // See bug #32858
 
                $text = $this->getNativeData();
                $pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
 
-               return new JavaScriptContent( $pst );
+               return new static( $pst );
        }
 
-       protected function getHtml( ) {
+       /**
+        * @return string JavaScript wrapped in a <pre> tag.
+        */
+       protected function getHtml() {
                $html = "";
                $html .= "<pre class=\"mw-code mw-js\" dir=\"ltr\">\n";
-               $html .= $this->getHighlightHtml( );
+               $html .= htmlspecialchars( $this->getNativeData() );
                $html .= "\n</pre>\n";
 
                return $html;
        }
+
 }