content: Refactor normalization of line endings code
authorKunal Mehta <legoktm@member.fsf.org>
Tue, 16 Aug 2016 21:58:15 +0000 (14:58 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 23 Aug 2016 18:09:59 +0000 (11:09 -0700)
commit85034abca5fa4879ab206ccb010ab1c37d8b87f3
tree6146fa728b49cb8dd509f3c1d31fc4b96fbaf8ed
parentd7c4e65fddc7a737395cb1dbaedb4d51eff3cc43
content: Refactor normalization of line endings code

The code that normalizes line endings ("\r\n" and "\r" to "\n") and
trims trailing whitespace is buried in Parser::preSaveTransform(), and
was duplicated to TextContent in 96b6afb31dfcff, as non-wikitext content
models should still be normalizing line endings.

This splits the duplicated code into
TextContent::normalizeLineEndings(), and utilize it in the Parser.
Additionally, expand the documentation of
TextContent::preSaveTransform() to document that subclasses should make
sure they normalize line endings during the PST stage.

And remove a useless rtrim() call from WikitextContent that did nothing.

Change-Id: I9094c671d4bbd23d75436f8f1d682d6dd6e6d2fc
includes/content/JsonContent.php
includes/content/TextContent.php
includes/content/WikitextContent.php
includes/parser/Parser.php
tests/phpunit/includes/content/TextContentTest.php