_filter_autop($text) [line break filter] adds line breaks to empty strings
| Project: | Drupal |
| Version: | 5.1 |
| Component: | filter.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
This actually is in 5.1 and 6, too. Tagging it as 5.2 since that's the current stable version.
If you pass in an empty string to this filter, you'll get two line breaks as a result. This causes problems with anything that might take action based on the result being an empty string. The case that bit me: CCK's text.module doesn't display plain text fields if they are empty, but would if they had an input format. It was the difference between calling check_markup() and check_plain(), with the former eventually calling the line break converter.
From a little testing, the first preg_replace line on 1204 seems to be at fault:
$chunk = preg_replace('|\n*$|', '', $chunk) ."\n\n"; // just to make things a little easier, pad the end
I'll take the comment at face value, but the problem still exists for empty strings. I'd suggest just bailing out at the beginning of the function, since there's no real reason to subject an empty string to all of those regexp calls:
function _filter_autop($text) {
if (!$text) {
return $text;
}
...
#1
Duplicate of #103079
Somehow I had the 5.1 filter.module in my 5.2 install. The issue above and relevant commit fixes the issue.