Merge "Split the 'mediawiki.htmlform' module code into multiple files"
[lhc/web/wiklou.git] / includes / content / TextContent.php
index baea812..de650b9 100644 (file)
@@ -92,7 +92,7 @@ class TextContent extends AbstractContent {
         * Returns true if this content is not a redirect, and $wgArticleCountMethod
         * is "any".
         *
-        * @param bool $hasLinks If it is known whether this content contains links,
+        * @param bool|null $hasLinks If it is known whether this content contains links,
         * provide this information here, to avoid redundant parsing to find out.
         *
         * @return bool
@@ -149,7 +149,7 @@ class TextContent extends AbstractContent {
 
        /**
         * Returns a Content object with pre-save transformations applied.
-        * This implementation just trims trailing whitespace.
+        * This implementation just trims trailing whitespace and normalizes newlines.
         *
         * @param Title $title
         * @param User $user
@@ -160,6 +160,7 @@ class TextContent extends AbstractContent {
        public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
                $text = $this->getNativeData();
                $pst = rtrim( $text );
+               $pst = str_replace( [ "\r\n", "\r" ], "\n", $pst );
 
                return ( $text === $pst ) ? $this : new static( $pst, $this->getModel() );
        }