Make WordPress Core

Opened 15 years ago

Closed 9 years ago

Last modified 9 years ago

#9959 closed defect (bug) (fixed)

wp_rel_nofollow_callback adds too many rel/nofollow attributes

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.4 Priority: low
Severity: normal Version: 2.8
Component: Comments Keywords: has-patch needs-unit-tests
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 (4)

wp_rel_nofollow.txt (1.4 KB) - added by junsuijin 15 years ago.
formatting.php (81.5 KB) - added by junsuijin 15 years ago.
9959.patch (1.3 KB) - added by junsuijin 15 years ago.
9959.diff (1.8 KB) - added by wonderboymusic 9 years ago.

Download all attachments as: .zip

Change History (21)

#1 @junsuijin
15 years ago

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

#2 @junsuijin
15 years ago

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

@junsuijin
15 years ago

#3 @junsuijin
15 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

#4 @junsuijin
15 years ago

  • Status changed from reopened to accepted

#5 @junsuijin
15 years ago

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

@junsuijin
15 years ago

#6 @Denis-de-Bernardy
15 years ago

  • Milestone changed from Future Release to 2.9

#7 @junsuijin
15 years ago

  • Keywords needs-patch removed

#8 @Denis-de-Bernardy
15 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">
';

#10 follow-up: @Denis-de-Bernardy
15 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">

#11 @aaroncampbell
15 years ago

  • Cc aaroncampbell added

#12 @ryan
15 years ago

  • Milestone changed from 2.9 to Future Release

#13 in reply to: ↑ 10 @dilbert4life
13 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.

#14 @chriscct7
10 years ago

  • Severity changed from minor to normal

@wonderboymusic
9 years ago

#15 @wonderboymusic
9 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from Future Release to 4.4
  • Owner changed from junsuijin to wonderboymusic
  • Status changed from accepted to assigned

#16 @wonderboymusic
9 years ago

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

In 34277:

Comments: in wp_rel_nofollow_callback(), account for the fact that a link might already have a rel attribute. Currently, if a link already has a rel, it will result it duplicate attributes on the element with conflicting values.

Adds unit tests.

Props junsuijin, wonderboymusic.
Fixes #9959.

#17 @SergeyBiryukov
9 years ago

In 35505:

Add missing @group to Tests_Rel_No_Follow.

See #9959.

Note: See TracTickets for help on using tickets.