Rel=nofollow set for TrustLevel 3

Hi.

I noticed that on my forum a user with user.has_trust_level?(TrustLevel[3]) == true has rel=nofollow on their links. For example:

https://forum.pololu.com/badges/3/leader

For the forum settings, I have “tl3 links no follow” unchecked, and “add rel nofollow to user content” checked, and “exclude rel nofollow domains” set to “pololu.com”.

The relevant code seems to be at https://github.com/discourse/discourse/blob/e55e2aff94959aecc28095875f5de351de26162f/app/models/post.rb#L206

Currently our forum is on version Version v1.6.0.beta12 +7 and here is the current plugins we are using:

Here is my Pry session trying to figure out what is going on:

[18] pry(main)> p = Post.where(id: 49157).first
=> #<Post:0x005580ef1f08b8
 id: 49157,
 user_id: 436,
 topic_id: 10535,
 post_number: 6,
 raw:
  "Based on the part that says `console=ttyS0,115200`, it looks like your Raspberry Pi is configured to use the UART as a console, which will interfere with using it to control the Qik.  I recommend following the instructions from this blog post to get the UART working on your Raspberry Pi 3:\n\nhttp://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two\n\nPlease note that these instructions also involve disabling and Bluetooth and WiFi.\n\n--David",
 cooked:
  "<p>Based on the part that says <code>console=ttyS0,115200</code>, it looks like your Raspberry Pi is configured to use the UART as a console, which will interfere with using it to control the Qik.  I recommend following the instructions from this blog post to get the UART working on your Raspberry Pi 3:</p>\n\n<p><a href=\"http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two\" class=\"onebox\" target=\"_blank\" rel=\"nofollow\">http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two</a></p>\n\n<p>Please note that these instructions also involve disabling and Bluetooth and WiFi.</p>\n\n<p>--David</p>",
 created_at: Wed, 03 Aug 2016 16:33:48 UTC +00:00,
 updated_at: Thu, 11 Aug 2016 20:21:40 UTC +00:00,
 reply_to_post_number: 5,
 reply_count: 0,
 quote_count: 0,
 deleted_at: nil,
 off_topic_count: 0,
 like_count: 0,
 incoming_link_count: 8,
 bookmark_count: 0,
 avg_time: 43,
 score: 33.75,
 reads: 8,
 post_type: 1,
 vote_count: 0,
 sort_order: 6,
 last_editor_id: 436,
 hidden: false,
 hidden_reason_id: nil,
 notify_moderators_count: 0,
 spam_count: 0,
 illegal_count: 0,
 inappropriate_count: 0,
 last_version_at: Wed, 03 Aug 2016 18:58:29 UTC +00:00,
 user_deleted: false,
 reply_to_user_id: 12636,
 percent_rank: 0.0,
 notify_user_count: 0,
 like_score: 0,
 deleted_by_id: nil,
 edit_reason: nil,
 word_count: 79,
 version: 2,
 cook_method: 1,
 wiki: false,
 baked_at: Thu, 11 Aug 2016 20:21:40 UTC +00:00,
 baked_version: 1,
 hidden_at: nil,
 self_edits: 3,
 reply_quoted: false,
 via_email: false,
 raw_email: nil,
 public_version: 2,
 action_code: nil>
[19] pry(main)> p.user.has_trust_level?(TrustLevel[3])
=> true
[20] pry(main)> SiteSetting.tl3_links_no_follow
=> false
[21] pry(main)> p.cooked.grep "nofollow"
NoMethodError: undefined method `grep' for #<String:0x005580ef22b850>
from (pry):21:in `__pry__'
[22] pry(main)> p.cooked.include? "nofollow"
=> true
[23] pry(main)> p.rebake!
=> true
[24] pry(main)> p.cooked.include? "nofollow"
=> false
[25] pry(main)> p.save!
=> true
[26] pry(main)> p = Post.where(id: 49157).first
=> #<Post:0x005580ef89dcb0
 id: 49157,
 user_id: 436,
 topic_id: 10535,
 post_number: 6,
 raw:
  "Based on the part that says `console=ttyS0,115200`, it looks like your Raspberry Pi is configured to use the UART as a console, which will interfere with using it to control the Qik.  I recommend following the instructions from this blog post to get the UART working on your Raspberry Pi 3:\n\nhttp://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two\n\nPlease note that these instructions also involve disabling and Bluetooth and WiFi.\n\n--David",
 cooked:
  "<p>Based on the part that says <code>console=ttyS0,115200</code>, it looks like your Raspberry Pi is configured to use the UART as a console, which will interfere with using it to control the Qik.  I recommend following the instructions from this blog post to get the UART working on your Raspberry Pi 3:</p>\n\n<p><a href=\"http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two\" class=\"onebox\" target=\"_blank\" rel=\"nofollow\">http://www.briandorey.com/post/Raspberry-Pi-3-UART-Boot-Overlay-Part-Two</a></p>\n\n<p>Please note that these instructions also involve disabling and Bluetooth and WiFi.</p>\n\n<p>--David</p>",
 created_at: Wed, 03 Aug 2016 16:33:48 UTC +00:00,
 updated_at: Thu, 11 Aug 2016 20:24:29 UTC +00:00,
 reply_to_post_number: 5,
 reply_count: 0,
 quote_count: 0,
 deleted_at: nil,
 off_topic_count: 0,
 like_count: 0,
 incoming_link_count: 8,
 bookmark_count: 0,
 avg_time: 43,
 score: 33.75,
 reads: 8,
 post_type: 1,
 vote_count: 0,
 sort_order: 6,
 last_editor_id: 436,
 hidden: false,
 hidden_reason_id: nil,
 notify_moderators_count: 0,
 spam_count: 0,
 illegal_count: 0,
 inappropriate_count: 0,
 last_version_at: Wed, 03 Aug 2016 18:58:29 UTC +00:00,
 user_deleted: false,
 reply_to_user_id: 12636,
 percent_rank: 0.0,
 notify_user_count: 0,
 like_score: 0,
 deleted_by_id: nil,
 edit_reason: nil,
 word_count: 79,
 version: 2,
 cook_method: 1,
 wiki: false,
 baked_at: Thu, 11 Aug 2016 20:24:29 UTC +00:00,
 baked_version: 1,
 hidden_at: nil,
 self_edits: 3,
 reply_quoted: false,
 via_email: false,
 raw_email: nil,
 public_version: 2,
 action_code: nil>
[27] pry(main)> p.cooked.include? "nofollow"
=> true

When I call rebake! on the post, it does not have the “nofollow” but when I save it and reload it from the database, it does.

Ryan

6 Likes

Possibly a bug, @eviltrout can have a look tomorrow.

2 Likes

What happens if you rebake with the “Rebuild HTML” button in the menu for the post?

3 Likes

We upgraded to latest overnight, and I notice that links in my posts there are now “nofollow” - and I’m TL4. I don’t know for certain, but I’ll be very surprised if any settings were deliberately changed.

Good question. It keeps the rel=nofollow in there. (That was the first thing I tried, but I forgot to mention it!)

1 Like

Now I look, my links and @cpradio’s links in this topic are “nofollow”, but we’re both TL3 here.

Confused about the "Nice Share" badge

2 Likes

I’ve noticed that with my links as well.

Personally, I don’t care a whit whether or not any links I post are nofollow or not.

I assumed the Setting had been changed and have not checked on my localhost (yet).

If the Setting hasn’t been changed and it is a bug I imagine there will be a lot of members that do w ant this “perk”.

EDIT
Just checked on localhost with a TL3 members post.
I don’t know why the “onebox” is there, but there isn’t a “nofollow”

<a href="https://www.google.com/" 
class="onebox" target="_blank">
https://www.google.com/
</a>

EDIT
Spoke too soon, nofollow is there now.
(a delayed onebox thing?)

<a href="https://www.google.com/" 
class="onebox" target="_blank" 
rel="nofollow">
https://www.google.com/
</a>
2 Likes

It seems to involve this Setting

add rel nofollow to user content
Add rel nofollow to all submitted user content, except for internal links (including parent domains). If you change this, you must rebake all posts with: “rake posts:rebake”

With that disabled links do not get a rel nofollow.

With it enabled, links get a rel nofollow regardless of the TL3 setting.

I found a bug in our post processing code where nofollow was being applied by mistake. Here’s a fix:

https://github.com/discourse/discourse/commit/aef954784a99f27e799c193e7e15aefbc2083c82

It will require a rebake for the posts where the bug applies though :frowning:

11 Likes