@@ -2547,10 +2547,20 @@ | ||
2547 | 2547 | |
2548 | 2548 | sub noFollow { |
2549 | 2549 | my($html) = @_; |
2550 | - $html =~ s/(<a href=.+?)>/$1 rel="nofollow">/gis; | |
2550 | + $html =~ s/(<a\s+(?:[^>]*?\s)?href=[^>]+?)>/&_noFollowStr($1)/geis; | |
2551 | 2551 | return $html; |
2552 | 2552 | } |
2553 | 2553 | |
2554 | +sub _noFollowStr { | |
2555 | + my($str) = @_; | |
2556 | + next unless ($str =~ /href="?(.*?)(?:"|\s|$)/); | |
2557 | + my $url = $1; | |
2558 | + my $regex = getCurrentStatic('nofollow_exclude_regex'); | |
2559 | + if (!$regex || $url !~ $regex) { | |
2560 | + $str .= ' rel="nofollow"'; | |
2561 | + } | |
2562 | + return $str . '>'; | |
2563 | +} | |
2554 | 2564 | |
2555 | 2565 | |
2556 | 2566 | # DOCUMENT after we remove some of this in favor of |