Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#10997 closed defect (bug) (fixed)

XHTML in comments_popup_link title attribute

Reported by: ewestp Owned by: xenlab
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8.4
Component: Comments Keywords: has-patch needs-testing
Focuses: Cc:


If a post title contains XHTML markup, the markup is included in the title attribute of the Comments link. See http://wordpress.org/support/topic/205790. To fix the problem, I suggest that line 973 in wp-includes/comments-template.php (version 2.8.5) be changed from

$title = esc_attr( get_the_title() );


$title = the_title_attribute('echo=0');

Attachments (2)

comment-template.php.diff (474 bytes) - added by ewestp 6 years ago.
Changed the line described above
10997-2.diff (453 bytes) - added by xenlab 6 years ago.
Refreshed the patch against 2.9-beta2 (r12338)

Download all attachments as: .zip

Change History (9)

comment:1 @scribu6 years ago

  • Milestone changed from Unassigned to 2.9

@ewestp6 years ago

Changed the line described above

comment:2 @ewestp6 years ago

  • Keywords has-patch added

comment:3 @scribu6 years ago

Related: #11040

comment:4 @ewestp6 years ago

Here is a simple test to highlight the problem.

1) Using the default theme, make a new post with the title

The &lt;em&gt; tag adds <em>emphasis</em>

2) On the front page, mouse over the permalink made from the post title. The title attribute looks nice--no tags around the word 'emphasis'.

3) Mouse over the link to the post's comments. The title attribute looks messy because there are tags around the word 'emphasis' which obviously don't belong there.

Why aren't the links' title attributes consistent? Because the permalink uses the_title_attribute() to construct a clean title attribute (a function that seems to have been made expressly for that purpose), and comments_popup_link() does not.

If you use the search-everything plugin with highlighting enabled, search for any of the words in the post's title and witness the horror that is the title attribute of the comments link.

@xenlab6 years ago

Refreshed the patch against 2.9-beta2 (r12338)

comment:5 @xenlab6 years ago

  • Cc wp@… added
  • Owner set to xenlab
  • Status changed from new to accepted

Patch has gone stale, so I refreshed it.

comment:6 @xenlab6 years ago

  • Keywords needs-testing added

comment:7 @markjaquith6 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [12362]) Strip HTML from comments_popup_link title attribute. props ewestp, xenlab. fixes #10997

Note: See TracTickets for help on using tickets.