Since my provider upgraded to php 5.2 I notice that

_filter_autop('') -> returns </p> and not an empty string or <p></p>

Fixed it for now by putting this on top of _filter_autop

  if ($text === "") {  
    return $text;
  }

This was especially visible with the image module since all images have an empty body on my site...
it generated


<img src="someimageurl" alt="xxx" title="xxx"  class="image preview" width="413" height="550" /></p>

which is invalid html

CommentFileSizeAuthor
#4 _filter_autop.patch1.19 KByched

Comments

bwynants’s picture

Installed PHP 5.2 on my computer

same issue...

empty string gets first replaced by 

<p>
</p>

then 
 
$chunk = preg_replace('!(</?'. $block .'[^>]*>)\s*</p>!', "$1", $chunk);

removes the first <p> and leaves the </p> in place

I'm not that familiar with reg exps so I leave this for the experts...

definetly not happening before 5.2

bwynants’s picture

Version: 4.7.x-dev » 5.0

same seems to happen on drupal 5

this is the cck output for an empty field.....

<div class="field-item"></p>
</div>
ChristopherFritz’s picture

Version: 5.0 » 5.1

I just wanted to add, I had the same issue (while using Taxonomy context). The given solution [if ($text === "") { return $text; } ] works like a charm (thanks!)

This is a real problem for those using XHTML (application/xhtml+xml), and it appears to be an easy solution.

$Id: filter.module,v 1.160 2007/01/12 07:27:21 unconed Exp $

yched’s picture

Version: 5.1 » 6.x-dev
Status: Active » Needs review
StatusFileSize
new1.19 KB

This should be a better fix - there is a mistake in one of the regexps in _filter_autop
Moving to Drupal 6, since this should be fixed here first, then backported.

The patch is for D6, but should apply to D5 (with an offset).

bwynants’s picture

Status: Needs review » Reviewed & tested by the community

seems to be working just fine. Thx!

dries’s picture

Version: 6.x-dev » 5.x-dev

Committed to CVS HEAD.

bryan kennedy’s picture

Version: 5.x-dev » 4.7.6

This is an issue in the latest version of 4.7 as well. At least for me.

drumm’s picture

Committed to 5.x;

killes@www.drop.org’s picture

Status: Reviewed & tested by the community » Fixed

applied

Anonymous’s picture

Status: Fixed » Closed (fixed)