• Hi Scott πŸ™‚ !

    As you asked me, here is the bug I’ve discovered on my website.
    The email addresses hidden by the native WP function antispambot are now parsed since the 1.6.0 release but give :
    <a href="http://domain.tld/current_page(post)/mailto:mail@domain.tld">mail@domain.tld</a>
    You can notice that http://domain.tld/current_page(post)/ have been added just before the email address, instead of stay untouched :).
    The current_page(post) slug is linked to the page or post where the email have been found.

    PS. You’ll can see the “true” generated antispambot work by doing a view source of this page and search for the code tag containing the email address πŸ˜‰

    TIA, Scott πŸ™‚ !!

    Amicably,

    Pierre.

    https://wordpress.org/plugins/simply-static/

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter Pierre_02

    (@pierre_02)

    Hi Scott πŸ™‚ !

    I have tried the last release (1.6.2) but the bug still exist. If I don’t call ‘add_filter’ everything works fine. But if I do it (like in the line bellow : `add_filter(‘the_content’,’search_and_replace_email’);
    the_content();`

    function search_and_replace_email ($string) {
    $pattern = "/[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})/i";
    	preg_match_all($pattern, $string, $matches);
    	foreach ($matches[0] as $email)  {
    		$string = str_replace($email, antispambot($email), $string);
    	}
    	$string = str_replace("mailto:", antispambot("mailto:"), $string);
    	return $string;
    }

    <a href="http://domain.tld/contact/mailto:mail@domain.tld">mail@domain.tld</a>
    I think that your function is “lost” as the antispambot is passed before and Simply Static think that it is a “standard” URL :(…

    Any solution to protect email ?

    TIA.

    Amicably,

    Pierre.

    Thread Starter Pierre_02

    (@pierre_02)

    Hi Scott πŸ™‚ !

    It makes a long time πŸ™‚ !! I would like to suggest a feature about the email address obfuscation.
    As SS have problem when email are protected by the native WP function “antispambot” when it’s called before the static generation of webpages, I’ve stopped to use it. But I’d like to ask you if you can implement it by your side :).
    So BTW, each time SS will find an URL beginning by “mailto:” this is YOUR plugin that will do the job by calling the “antispambot” function :).
    Like, actually, we can’t use form (at least in an easy way), it will be a really cool feature to protect our email addresses ;).

    TIA.

    Amicably,

    Pierre.

    Hi Pierre,

    Sorry for taking so long to respond to this. I’ve added this to our bug tracker and I’ll take a look at this as soon as I can. Thank you for the long explanation, that helps a bunch!

    Best,
    Scott

    Hi Pierre,

    I’m having a hard time recreating the issue you’re running into. I’m using the WordPress Twenty Fifteen theme and every page where I try to add a mailto:myemail@example.com the email comes across exactly as that. I’m not seeing the behavior you describe in posts or comments on either the WordPress site or when it gets exported to a static site.

    Is there a plugin that is modifying the email addresses, or a specific theme?

    Best,
    Scott

    Thread Starter Pierre_02

    (@pierre_02)

    Hi Scott :).

    Sorry I did not be clear enough… As I can’t use forms with static content, I use email addresses in my contact page as link like this: <a href="mailto:mymailaddress@mydomain.com">Contact me</a> but as I don’t want that spambots recovers easyly my emails addresses, I write a special function that parse the content and transform each email address it found by using the native WP function “antispambot”.
    So, when SS parse my pages it see the email link that have been transformed by the native function of WP. An it is unable to realize that’s an email address, that the problem.
    So I stop to use my function to protect links with “mailto” and everything is workin now.
    What I ask to you is to do the job from the plugin. Exactly as I was doing it :).
    So, as soon the plugin discover a link containing a “mailto” it call itself the native WP function “antispambot” and everybody will be happy, because emails addresses will be correctly protected :)!
    As I said you in my last answer : Like, actually, we can’t use form (at least in an easy way), it will be a really cool feature to protect our email addresses ;).

    I hope that this time I’ve been enough clear ;).

    Amicably,

    Pierre.

    Thanks Pierre, that helps. Would you be able to send me the custom function you’re using to transform the email addresses?

    Best,
    Scott

    Thread Starter Pierre_02

    (@pierre_02)

    Hi Scott πŸ™‚ !

    The function I use to parse email addresses is in this thread :).
    It search for email addresses in the content part (but I think you’ll have to adapt it to search everywhere) and call the native WP function antispambot for each address.

    Happy to know that it will be implemented in a future release πŸ™‚ !

    Amicably,

    Pierre.

    Ah, you did indeed, my apologies. I’ll try it out and see what I can do.

    Best,
    Scott

    Thread Starter Pierre_02

    (@pierre_02)

    Hi Scott πŸ™‚ !

    You’re kidding πŸ™‚ ! No need for apology here, I will be really happy when you have added this functionnality πŸ™‚ !

    TIA.

    Amicably,

    Pierre.

    Hi Pierre,

    I finally had to take a look at this. Unfortunately, I was unable to recreate the issue you were running into.

    I create a page with the following HTML:

    <a href="mailto:scott@scottblaine.com">email scott</a>

    And, with the antispambot function, WordPress converted it to this:

    <a href="mailto:scott@scottblaine.com">email scott</a>

    So far, so good.

    When I generated the static site, this is what Simply Static had for that link:

    <a href="mailto:scott@scottblaine.com">email scott</a>

    It’s slightly different than what I had on WordPress, but that’s because the antispambot function slightly adjusts the result each time you load the page, so that’s to be expected.

    Are you certain that the mailto links look correct on the live WordPress site? Simply Static should be ignoring any href’s that don’t already start with the WordPress URL.

    Best,
    SCott

    Thread Starter Pierre_02

    (@pierre_02)

    Hi Scott πŸ™‚ !

    Sorry, but I’m really don’t sure of what I understand :)… My code wasn’t working because I used the antispambot before the generation of the static files from your plugin and BTW “loosing” it with the genrerated href. But if that’s your plugin who do the work during its browsing, I think that everything would be ok :). I suggest that you pass the “mailto:” and the email address to the spambot function to totally waste spambots ;).

    TIA,

    Amicably,

    Pierre.

    Hi Pierre,

    Sorry if that wasn’t terribly clear. What I’m trying to say is that Simply Static shouldn’t be adjusting any links that start with “mailto:”. As a result, I’m not sure why it’s adjusting them on your site. Would you be able to send me the URL for your WordPress site? scott@codeofconduct.co

    Best,
    Scott

    Thread Starter Pierre_02

    (@pierre_02)

    Hi Scott πŸ™‚ !

    I’m sorry, surely my fault as english is not my natural language :$… So, everything works very fine with your plugin. Forget what I ask you at the beginning of this thread because, before, I was doing some treatments to the content before SS parse the posts ; “loosing” it.
    We will continue now, this discussion, ok?
    I would like, simply, that you call the function ‘antispambot’ (from WP) during the generation of all the static pages. BTW all the email addresses will be “hidden” to spambots :).
    I hope this time I managed to be clear enough :)…

    I wish you a marvellous and delicious christmas and a happy new year in advance πŸ™‚ !!

    Amicably,

    Pierre.

    Hi Pierre!

    Thank you for that explanation, that helps a bunch! So, you would like Simply Static to call the antispambot function any time it encounters a mailto: link.

    That’s slightly outside of Simply Static’s core functionality, but I’ll certainly add it to my development list and think of how to best implement it. I may create a separate plugin for you since I haven’t heard any other requests for it yet.

    Best,
    Scott

    Thread Starter Pierre_02

    (@pierre_02)

    Hi Scott :)!

    Great and cool regardless of the solution you adopt :)! I think that every user should be interested by the obfuscation of the email ;). But here to regardless of the option you will adopt I will be happy to use it :)! Perhaps just a checkbox in the settings should do the trick :).

    TIA,

    Once again, I wish you a marvellous and delicious christmas and a happy new year in advance Scott πŸ™‚ !!

    Scott.

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Problem with parsed native WP function antispambot’ is closed to new replies.