[drupal-devel] [bug] Aggregator module: incorrect process html in description when title is blank

edhel drupal-devel at drupal.org
Mon Mar 28 04:59:28 UTC 2005


Issue status update for http://drupal.org/node/19573

 Project:      Drupal
 Version:      4.5.2
 Component:    aggregator.module
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  edhel
 Updated by:   edhel
 Status:       active

It's problem of aggregator.module in Drupal 4.5.x and 4.6 also. I have
detected this problem when "aggregate" posts from LiveJournal.com which
have blank titles and html in description at the same time.
In aggregator.module in aggregator_parse_feed() at line 501 (Drupal
4.5.2) there is such code:

<?php
if ($item['TITLE']) {
      $title = $item['TITLE'];
    }
    else {
      $title = preg_replace('/^(.*)[^\w;&].*?$/', "\\1",
truncate_utf8($item['DESCRIPTION'], 40));
    }
?>


I suppose that it is incorrect preg_replace call as since:
1) it doesn't cut html tags
2) it may incorrectly work with national chars (i.e. \w): maybe
ereg_replace is better solution?
For correct processing I changed this code to such:

<?php
if ($item['TITLE']) {
      $title = $item['TITLE'];
    }
    else {
//      $title = preg_replace('/^(.*)[^\w;&].*?$/', "\\1",
truncate_utf8($item['DESCRIPTION'], 40));
        $title = ereg_replace('<.*?(>|$)', '',
truncate_utf8($item['DESCRIPTION'], 40));
        $title = ereg_replace('/^(.*?)[^[:alnum:];&].*?$/',
"\\1", $title) . "...";
    }
?>




edhel




More information about the drupal-devel mailing list