Tags:
create new tag
, view all tags

Feature Proposals » Enable Anti-Spam Padding for Guest users

Summary

Current State: Developer: Reason: Date: Concerns By: Bug Tracking: Proposed For:
MergedToCore PeterJones AcceptedByReleaseMeeting 2016-11-17   TWiki:Item7762 KampalaRelease

Edit Form

TopicSummary:
CurrentState:
CommittedDeveloper:
ReasonForDecision:
DateOfCommitment:   Format: YYYY-MM-DD
ConcernRaisedBy:
BugTracking:
OutstandingIssues:
RelatedTopics:
InterestedParties:
ProposedFor:
TWikiContributors:
 

Motivation

AntiSpamPadding is useful to stop robots spamming but Is this needed for authenticated users?

request made after consulting with Peter

Description and Documentation

AntiSpamPadding is useful to stop robots spamming but the output is not aesthetically pleasing and the emails cannot be copied/pasted. Is this needed for authenticated users? This is a request to have a configuration option to enable the padding only if the user is not authenticated.

Add a variable such as $TWiki::cfg{AntiSpam}{EmailGuestPadding} to the LocalSite.cfg and add some code in lib/TWiki/Render.pm to check this.

Examples

Impact

WhatDoesItAffect: Rendering

Implementation

-- Contributors: Peter Jones - 2016-11-17

Discussion

Looks good. To be specific, I think it is good to offer both options, the existing $TWiki::cfg{AntiSpam}{EmailPadding}, and a new $TWiki::cfg{AntiSpam}{EmailGuestPadding} option that depends on the login context of the user.

-- Peter Thoeny - 2016-11-17

Feature proposal accepted by KampalaReleaseMeeting2016x11x17. I put Pete Jones down as committed developer, let me know if you'd like to change this.

-- Peter Thoeny - 2016-11-17

How about in lib/TWiki/Render.pm

sub _externalLink {

my $authenticated = TWiki::Func::getContext('authenticated');

if( $url =~ /^mailto:/i ) {
        if( $TWiki::cfg{AntiSpam}{EmailPadding} ){
            if (($TWiki::cfg{AntiSpam}{EmailGuestPadding}) && (!$authenticated)){
              $url =~  s/(\@[\w\_\-\+]+)(\.)/$1$TWiki::cfg{AntiSpam}{EmailPadding}$2/;
              if ($text) {
                  $text =~ s/(\@[\w\_\-\+]+)(\.)/$1$TWiki::cfg{AntiSpam}{EmailPadding}$2/;
              }
            } 
        }
        if( $TWiki::cfg{AntiSpam}{HideUserDetails} ) {
            # Much harder obfuscation scheme. For link text we only encode '@'
            # See also Item2928 and Item3430 before touching this
            $url =~ s/(\W)/'&#'.ord($1).';'/ge;
            if ($text) {
                $text =~ s/\@/'&#'.ord('@').';'/ge;
            }
        }

    } elsif
.
.
.

-- Peter Jones - 2016-11-21

I solved it with some modification, so that one or the other setting can be used.

Patch:

Index: TWiki.spec
===================================================================
--- TWiki.spec   (revision 30274)
+++ TWiki.spec   (working copy)
@@ -695,6 +695,11 @@
 # rendered as fred@user.co.NOSPAM.ru
 $TWiki::cfg{AntiSpam}{EmailPadding} = '';
 
+# **STRING 50**
+# Same as <tt>{AntiSpam}{EmailPadding}</tt>, except that the spam
+# padding is only done for non-authenticated users.
+$TWiki::cfg{AntiSpam}{EmailGuestPadding} = '';
+
 # **BOOLEAN**
 # Normally TWiki stores the user's sensitive information (such as their e-mail
 # address) in a database out of public view. It also obfuscates e-mail
Index: TWiki/Render.pm
===================================================================
--- TWiki/Render.pm   (revision 30274)
+++ TWiki/Render.pm   (working copy)
@@ -1024,7 +1024,13 @@
     my $opt = '';
     my $icn = '';
     if( $url =~ /^mailto:/i ) {
-        if( $TWiki::cfg{AntiSpam}{EmailPadding} ) {
+        my $twiki = $this->{session};
+        if( $TWiki::cfg{AntiSpam}{EmailGuestPadding} && !$twiki->inContext( 'authenticated' ) ) {
+            $url =~  s/(\@[\w\_\-\+]+)(\.)/$1$TWiki::cfg{AntiSpam}{EmailGuestPadding}$2/;
+            if ($text) {
+                $text =~ s/(\@[\w\_\-\+]+)(\.)/$1$TWiki::cfg{AntiSpam}{EmailGuestPadding}$2/;
+            }
+        } elsif( $TWiki::cfg{AntiSpam}{EmailPadding} ) {
             $url =~  s/(\@[\w\_\-\+]+)(\.)/$1$TWiki::cfg{AntiSpam}{EmailPadding}$2/;
             if ($text) {
                 $text =~ s/(\@[\w\_\-\+]+)(\.)/$1$TWiki::cfg{AntiSpam}{EmailPadding}$2/;

-- Peter Thoeny - 2016-11-22

This is now MergedToCore.

-- Peter Thoeny - 2016-11-22

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2016-11-22 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.