Unverified Commit 72c76b73 authored by larowlan's avatar larowlan
Browse files

Issue #2359389 by harsha012, hgoto, jeqq, fago, sureshcj, larowlan: Call to a...

Issue #2359389 by harsha012, hgoto, jeqq, fago, sureshcj, larowlan: Call to a member function filters() on a non-object in core/modules/text/text.module on line 83
parent 354462c6
......@@ -207,6 +207,15 @@ public function testLength() {
$this->assertTextSummary($text, "<p>\nHi\n</p>\n<p>\nfolks\n<br />\n!\n</p>", $format, $i++);
}
/**
* Test text_summary() returns an empty string without any error when called
* with an invalid format.
*/
public function testInvalidFilterFormat() {
$this->assertTextSummary($this->randomString(100), '', 'non_existent_format');
}
/**
* Calls text_summary() and asserts that the expected teaser is returned.
*/
......
......@@ -81,11 +81,11 @@ function text_summary($text, $format = NULL, $size = NULL) {
// Retrieve the filters of the specified text format, if any.
if (isset($format)) {
$filters = FilterFormat::load($format)->filters();
$filter_format = FilterFormat::load($format);
// If the specified format does not exist, return nothing. $text is already
// filtered text, but the remainder of this function will not be able to
// ensure a sane and secure summary.
if (!$filters) {
if (!$filter_format || !($filters = $filter_format->filters())) {
return '';
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment