WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 5 months ago

#9959 accepted defect (bug)

wp_rel_nofollow_callback adds too many rel/nofollow attributes

Reported by: Denis-de-Bernardy Owned by: junsuijin
Milestone: Future Release Priority: low
Severity: normal Version: 2.8
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

if you insert a link in a comment, like:

<a href="foo" rel="bar nofollow">

wp_rel_nofollow_callback() turns that into:

<a href="foo" rel="bar nofollow" rel="nofollow">

Here's a correct implementation of a strip_nofollow() function:

http://plugins.trac.wordpress.org/browser/sem-dofollow/trunk/sem-dofollow.php

We'd probably want to do the same in WP, and then reverse it: add rel=nofollow if no rel is present, and add a nofollow to the rel if it's not in there already.

Attachments (3)

wp_rel_nofollow.txt (1.4 KB) - added by junsuijin 6 years ago.
formatting.php (81.5 KB) - added by junsuijin 6 years ago.
9959.patch (1.3 KB) - added by junsuijin 6 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 @junsuijin6 years ago

  • Owner set to junsuijin
  • Status changed from new to reviewing

comment:2 @junsuijin6 years ago

  • Resolution set to worksforme
  • Status changed from reviewing to closed

@junsuijin6 years ago

@junsuijin6 years ago

comment:3 @junsuijin6 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

comment:4 @junsuijin6 years ago

  • Status changed from reopened to accepted

comment:5 @junsuijin6 years ago

  • Cc junsuijin@… added
  • Keywords has-patch added

@junsuijin6 years ago

comment:6 @Denis-de-Bernardy6 years ago

  • Milestone changed from Future Release to 2.9

comment:7 @junsuijin6 years ago

  • Keywords needs-patch removed

comment:8 @Denis-de-Bernardy6 years ago

Some test data to play with

$text = '
<a href="foo" rel="tag nofollow ext">
<a href="foo" rel="nofollow ext">
<a href="foo" rel="tag ext">
<a href="foo" rel ="tag">
<a href="foo" rel="">
<a href="foo" rel
="">
<a href="foo" rel= "">
<a href="foo">
<
a href="foo">
';

comment:10 follow-up: @Denis-de-Bernardy6 years ago

per IRC discussion, there also is a separate issue. unless I'm mistaking, it's possible to add a link in a comment without nofollow, as such:

<a
href="url">

comment:11 @aaroncampbell6 years ago

  • Cc aaroncampbell added

comment:12 @ryan5 years ago

  • Milestone changed from 2.9 to Future Release

comment:13 in reply to: ↑ 10 @dilbert4life4 years ago

  • Cc dilbert4life added

Replying to Denis-de-Bernardy:

To prevent that, we could have it remove line breaks from the comment text, and then run the wp_rel_nofollow function. However, the original problem is still present in 3.1.1. I'll look into this using 9959.patch as a starting point.

comment:14 @chriscct75 months ago

  • Severity changed from minor to normal
Note: See TracTickets for help on using tickets.