API page: http://api.drupal.org/api/drupal/modules--field--modules--text--text.mod...

Describe the problem you have found:
The text_summary function has an early exit, if a '

' tag will be found in the content. Sadly i discovered a problem if the author of the html body content didn't placed it correctly:

My body <div>is fine<!--break--></div>

This causes an shortened teaser e.g.:
My body <div>is fine
..and break up the div-structure of the surrounding page.

Not only the author of this body can make this mistake, also the ckeditor / wysiwyg didn't care about.

So i have to handle this issue on the theming layer, but i would prefer a central solution in the text.module.

Here is my patch:

Index: text.module
===================================================================
--- text.module (Revision 121)
+++ text.module (Arbeitskopie)
@@ -361,15 +361,19 @@
   }   
 
   // If a valid delimiter has been specified, use it to chop off the summary.
+  $filters = filter_list_format($format);
   if ($delimiter !== FALSE) {
-    return substr($text, 0, $delimiter);
+    $summary =  substr($text, 0, $delimiter);
+    if (isset($filters['filter_htmlcorrector'])) {
+      $summary = _filter_htmlcorrector($summary);
+    }
+    return $summary;
   }   
 
   // We check for the presence of the PHP evaluator filter in the current
   // format. If the body contains PHP code, we do not split it up to prevent
   // parse errors.
   if (isset($format)) {
-    $filters = filter_list_format($format);
     if (isset($filters['php_code']) && $filters['php_code']->status && strpos($text, '<?') !== FALSE) {
       return $text;
     }   

Files: 
CommentFileSizeAuthor
#1 summary_html_corrector-1387560-1.patch1.05 KBoriol_e9g
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch summary_html_corrector-1387560-1.patch. Unable to apply patch. See the log in the details link for more information. View

Comments

oriol_e9g’s picture

Version: 7.9 » 8.x-dev
Status: Active » Needs work
Issue tags: +Needs tests
FileSize
1.05 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch summary_html_corrector-1387560-1.patch. Unable to apply patch. See the log in the details link for more information. View

First this will be fixed in D8 and then backported to D7, rolled a patch for Drupal 8 but we still need tests for this.

martin.weidner’s picture

Version: 8.x-dev » 7.x-dev

Hi,

I found a similar problem when using the openWysiwyg editor:
The text_summary() method was just cutting everything and the teaser was empty.

Therefore i inserted the following line to quickfix the problem:

function text_summary($text, $format = NULL, $size = NULL) {
  $text = strip_tags($text);

I know that now, all formatting gets lost in the teaser but at least there is displayed sth. Did I miss a setting or is my problem a bug within the function?

Best regards,
Martin

andypost’s picture

oriol_e9g’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs review » Closed (duplicate)
Issue tags: +Needs tests

Ok, go all to the other issue.

salvis’s picture

Status: Needs work » Needs review

I don't see how the two issues should be related. The other issue is about fixing the [node:summary] token only. This issue here shows up even if you don't use the [node:summary] token.

The token will obviously suffer if text_summary() doesn't work right, but just because preparing the token uses text_summary() doesn't mean the two issues are related. Both issues need to be fixed on their own.

Status: Needs review » Needs work

The last submitted patch, summary_html_corrector-1387560-1.patch, failed testing.

oriol_e9g’s picture

Version: 7.x-dev » 8.x-dev
oriol_e9g’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
andypost’s picture

Version: 7.x-dev » 8.x-dev
Status: Closed (duplicate) » Needs review
Issue tags: -Needs tests

Status: Needs review » Needs work

The last submitted patch, 1: summary_html_corrector-1387560-1.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.