Skip to content

Commit

Permalink
MDL-50153 messageinbound: Make messageinbound tests dos-safe
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed May 8, 2015
1 parent cba92dc commit 2d07240
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/tests/messageinbound_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public function test_messageinbound_handler_trim($file, $source, $expectedplain,
$messagedata->html = '';

list($message, $format) = test_handler::remove_quoted_text($messagedata);
$this->assertEquals($expectedplain, $message);

// Trim both the expected and the actual - we are not concerned about trailing whitespace.
$this->assertEquals(rtrim($expectedplain), rtrim($message));
$this->assertEquals(FORMAT_PLAIN, $format);
}

Expand All @@ -60,7 +62,9 @@ public function test_messageinbound_handler_trim($file, $source, $expectedplain,
$messagedata->html = $mime->getPart($htmlpartid)->getContents();

list($message, $format) = test_handler::remove_quoted_text($messagedata);
$this->assertEquals($expectedhtml, $message);

// Trim both the expected and the actual - we are not concerned about trailing whitespace.
$this->assertEquals(rtrim($expectedhtml), rtrim($message));
$this->assertEquals(FORMAT_PLAIN, $format);
}
}
Expand Down Expand Up @@ -103,7 +107,7 @@ public function message_inbound_handler_trim_testprovider() {

protected function read_test_file(\SplFileInfo $file, $fixturesdir) {
// Break on the --[TOKEN]-- tags in the file.
$tokens = preg_split('#(?:^|\n*)----([A-Z]+)----\n#', file_get_contents($file->getRealPath()),
$tokens = preg_split('#(?:^|[\r]?\n*)----([A-Z]+)----[\r]?\n#', file_get_contents($file->getRealPath()),
null, PREG_SPLIT_DELIM_CAPTURE);
$sections = array(
// Key => Required.
Expand Down

0 comments on commit 2d07240

Please sign in to comment.