bellroy / lesswrong-migrated

Automatically exported from code.google.com/p/lesswrong
Other
0 stars 0 forks source link

Comments fail to add "nofollow" for links that contain the string "lesswrong" #286

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a comment on lesswrong linking to http://www.jefftk.com/lesswrong.html
2. Example: http://lesswrong.com/lw/7fo/open_thread_september_2011/62l1

What is the expected output? What do you see instead?

    The generated html is:

      <p>Testing nofollow on
      <a href="http://www.jefftk.com/lesswrong.html">a link</a>
      that contains 'lesswrong' somewhere but doesn't point to
      lesswrong.com.</p>

    I would expect to see:

      <p>Testing nofollow on
      <a href="http://www.jefftk.com/lesswrong.html" rel="nofollow">
      a link</a> that contains 'lesswrong' somewhere but doesn't
      point to lesswrong.com.</p>

The code responsible for this appears to be:

    269  if not re.search('lesswrong|overcomingbias', res):
    270     res += ' rel="nofollow"'

In 
https://github.com/tricycle/lesswrong/blob/master/r2/r2/lib/contrib/markdown.py

Solving this properly is tricky.  Some links that should be left alone:

    http://foo.lesswrong.com
    http://lesswrong.com
    http://lesswrong.com/foo

Some links that should be nofollowed:

    http://www.jefftk.com/lesswrong.html
    http://lesswrong.jefftk.com

Original issue reported on code.google.com by jeff.t.k...@gmail.com on 19 Mar 2012 at 8:46

GoogleCodeExporter commented 9 years ago

Original comment by Matthew.Fallshaw on 3 Aug 2012 at 6:05