Create Parser::stripOuterParagraph to avoid code duplication
authorBartosz Dziewoński <matma.rex@gmail.com>
Sat, 22 Feb 2014 15:21:36 +0000 (16:21 +0100)
committerBrad Jorsch <bjorsch@wikimedia.org>
Thu, 15 May 2014 16:20:19 +0000 (12:20 -0400)
commitc3aa5ef597afcf9a10dc71ec09e22535f2ebc772
tree5a01be210a8e287112a79de1a2ad32c2940b37b5
parentee9d87560773b147ed0888377c6885a042af8cb1
Create Parser::stripOuterParagraph to avoid code duplication

We've had the logic for stripping the outer <p/> element in three
separate places. The version in OutputPage was missing the '$' at the
end of the regex, that was most likely a mistake caused by the
duplication.

Also, extend the logic in order not to generate invalid HTML if the
input contains more than one <p/> tag. Added tests for this and the
previous behaviour.

https://www.mail-archive.com/mediawiki-api@lists.wikimedia.org/msg03188.html

Change-Id: I6bb3597898324556df912a23a7ffc9ff250b8f58
includes/GlobalFunctions.php
includes/Message.php
includes/OutputPage.php
includes/parser/Parser.php
tests/phpunit/includes/parser/ParserMethodsTest.php