[wp-trac] [WordPress Trac] #12097: Inserting image captions sometimes result in malformed HTML

WordPress Trac wp-trac at lists.automattic.com
Sun Jan 31 13:30:56 UTC 2010


#12097: Inserting image captions sometimes result in malformed HTML
--------------------------+-------------------------------------------------
 Reporter:  essday        |       Owner:            
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  Media         |     Version:  2.9.1     
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 When adding an image with a caption to an HTML post, WP generates invalid
 HTML. In at least the case identified below, WP generates a DIV tag inside
 a P tag, which violates HTML standards and which results in undefined
 behavior depending on the browser being used.

 For background: http://wordpress.org/support/topic/291591

 To reproduce:

   * install stock WP 2.9.1 from scratch. No changes (eg. no themes and no
 plugins).
   * edit the default first post
   *  switch to HTML editor view
   * upload an image at the beginning of the post, using the same text for
 the image title, alternate text and caption
   * insert the image into the post as a thumbnail
   * save the post

 The text inside the editor should look like the following when you are
 done:

 {{{
 [caption id="attachment_3" align="alignnone" width="100" caption=
 "Blurred TV Icon"]<a href="http://wptesty.nfshost.com/wp-conten
 t/uploads/BlurredTVIcon.png"><img class="size-full wp-image-3
 " title="Blurred TV Icon" src="http://wptesty.nfshost.com/wp-con
 tent/uploads/BlurredTVIcon.png" alt="Blurred TV Icon" width="100
 " height="100" /></a>[/caption]Welcome to WordPress. This is your
  first post. Edit or delete it, then start blogging!
 }}}

 The resulting HTML generated by WP is:

 {{{
 <div class="entry">
 <p><div id="attachment_3" class="wp-caption alignnone" style="wi
 dth: 110px"><a href="http://wptesty.nfshost.com/wp-content/u
 ploads/BlurredTVIcon.png"><img class="size-full wp-image-3" titl
 e="Blurred TV Icon" src="http://wptesty.nfshost.com/wp-conten
 t/uploads/BlurredTVIcon.png" alt="Blurred TV Icon" width="100" h
 eight="100" /></a><p class="wp-caption-text">Blurred TV Icon<
 /p></div>Welcome to WordPress. This is your first post. Edit or del
 ete it, then start blogging!</p>
 </div>
 }}}

 For a live example, see http://wptesty.nfshost.com.

 NOTE: I am hosting this site myself and I may not leave it up for very
 long, so if you want to see the bug without having to set up WP yourself,
 please visit this URL sooner rather than later.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12097>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list