I would like to know what this code is good for which is found in spamspan.js file:

      // Replace each <spam class="t"></spam> with .
      if ($('span.t', this).length) {
        $('span.t', this).replaceWith('.');
      }

I can see it does replace the spamSpanAnchorTextClass with a ".", but currently I do not see why this is done.

In a custom module I am putting some email adresses in the spam span format like this

<span class="spamspan">
<span class="u">user</span>
@
<span class="d">domain</span>
(<span class="t">Anchor Text</span>)
</span>

But because of the code from spamspan.js shown above the anchortext is stripped out and instead the anchortext defaults to the email address.

Is this intended? If so, could someone explain why?

I took the code out of spamspan.js and then the anchortext is used as expected.

Comments

stefan.korn created an issue. See original summary.

stefan.korn’s picture

Title: spamspan.js and Anchor text » spamspan.js and anchortext
blake.thompson’s picture

Just ran into this issue myself, I'm also removing the replaceWith('.'); as I'm not sure why that's there.

vitalie’s picture

The module allows for obfuscation of the dot in email addresses (there's a setting for that). Internally, <span class="t">[dot]</span> is used to encode it. The javascript then has to replace it with a real dot.

If you need to use the spamspan markup directly, please see if this comment is of any help. https://www.drupal.org/node/2413627#comment-9593955

You're welcome to add a patch to README.txt if you want.

vitalie’s picture

Status: Active » Fixed

P.S. so instead of <span class="t">Anchor text</span> use <span class="a">Anchor text</span>

stefan.korn’s picture

Thank you for the explanation. So this change using the "a"-class for anchor text was introduced here i think: https://www.drupal.org/node/1167084

Had 7.x-1.2 installed on my site and there I could not see this change because 7.x-1.2 is not using it already.

Generally asking: Wouldn't it make sense to use the "t"-class for anchor text and use another class for the "."-obfuscation? Because the spamspan documentation here http://www.spamspan.com/ defines "t"-class for anchor text replacement and IMHO it is a little confusing if the Drupal spam span module uses "t"-class for "."-obfuscation.

If you are considering this as an improvement, I would looking into providing a patch for this if you like.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.