Support » Plugin: CryptX » Have an issue with escaping quotes pt2

  • It’s me again, having issues with escaping quotes again. So I’m working with a client using the Enfold theme. The plugin is working as intended, except that I suspect it’s running before the theme writes it to the page. So CryptX generates the JavaScript for Anti-spambot code such as :

    javascript:DecryptX('...');

    But when that code is concatenated with the rest of the page by the theme, it’s also done with single quotes. Which causes the link to break:

    <a href='javascript:DecryptX('...');'>Link</a>

    Could there be an option to maybe toggle which quotes are used? So in this case, i could make it use double-quotes to keep it working. Or if possible, not use quotes? I think that would improve compatibility a ton. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Another gotcha I just found, I don’t see a way to STOP CryptX from adding “mailto:” to links. I have about 100 links on an existing site that already have “mailto:”, i don’t need it added just encrypted. Can you add an option to toggle that as well?

    For the mailto: adding, i think this would work:

    function DeCryptString( s ) {
    	var n = 0;
    	var r = "";
    	var z = 0;
    	for( var i = 0; i < s.length/2; i++) {
    		z = s.substr(i*2, 1);
    	    n = s.charCodeAt( i*2+1 );
    	    if ( n >= 8364 )	{
    		    n = 128;
    	    }
    	    r += String.fromCharCode( n - z );
    	}
    	if (r.substring(0, 'mailto:'.length) != 'mailto:') r = 'mailto:' + r;
    	return r;
    }
    
    function DeCryptX( s ) {
    	location.href=DeCryptString( s );
    }

    I have new idea I thought I’d suggest. To avoid quotes altogether, you might be able to convert the hash into a long number. Such as base 10 or binary (base 2). That way you would only accept a number input, no quotes required and avoid any issues moving forward.

    Plugin Author Ralf Weber

    (@d3395)

    Hi Gabriel,

    first of all thanks for your help.
    Can you give me a link to a page where I can see the double mailto-effect?

    I’ll be working on it, but give me a little bit more time.

    And, how did you meant your last reply?

    Ralf

    I don’t have the example available still since I had to fix it on a clients site already. But the link is here: https://www.bsmg.net/contact-us/
    The site is using the Enfold theme with an Icon Box module (the sidebar where it says info@). Which is basically a widget with an area for a title, an icon and an option to link the title. The client had configured the title to be linked using this as the URL:

    mailto:john@example.com

    But when CryptX ran, it would see there was an email address, grab it but for some reason when it decrypted it, it kept the mailto. The script adds mailto whether it’s there or not. So my links ended up having mailto:mailto:john@example.com. So my modification was to add it only if it didn’t already exist.

    Regarding my last reply, if you can encode the hash into a number, you would avoid having to use quotes at all. So for example, on https://md5decrypt.net/en/Conversion-tools/ , I could encode:

    mailto:john@example.com -> 01101101 01100001 01101001 01101100 01110100 01101111 00111010 01101010 01101111 01101000 01101110 01000000 01100101 01111000 01100001 01101101 01110000 01101100 01100101 00101110 01100011 01101111 01101101

    Of course you would have to pad the front with zeroes to ensure it’s 8 bits to a byte because a number will chop those, but you get the idea. Or something a bit more robust like:

    function encode2(str) {
        return str.replace(/./g, function(c) {
            return ('00' + c.charCodeAt(0)).slice(-3);
        });
    }
    
    function decode2(str) {
        return str.replace(/.{3}/g, function(c) {
            return String.fromCharCode(c);
        });
    }

    So something like mailto:john@example.com -> 109097105108116111058106111104110064101120097109112108101046099111109

    I realize i’m just encoding the email address, you would be encoding the hash instead but it’s just a proof of concept. That help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.