? Success

User tests: Successful: Unsuccessful:

avatar zero-24
zero-24
3 Jun 2014

Tracker

http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_id=8103&tracker_item_id=33693

Code by Fiorino De Santo

How to test

make sure that the email cloaking still works as bevor.

avatar zero-24 zero-24 - open - 3 Jun 2014
avatar zero-24 zero-24 - change - 3 Jun 2014
Title
Use jQuery insteand of document.write on email cloak
[#33693] Use jQuery insteand of document.write on email cloak
avatar wilsonge
wilsonge - comment - 3 Jun 2014

I disagree with this. I think we should always look to raw javascript instead of jQuery if we can

avatar mbabker
mbabker - comment - 3 Jun 2014

Read the tracker item and you'll see why this is being proposed. It's not necessarily an issue with raw JS versus jQuery.

avatar phproberto
phproberto - comment - 4 Jun 2014

Yes. It's not an issue of raw JS vs jQuery. I think the real issue was the absence of the a div with an identifier. To fix that you do not require to use jQuery.

You should be able to replace:

jQuery('#cloak$rand').html('');

with:

document.getElementById('cloak$rand').innerHTML = '';

And the same for the other calls.

avatar zero-24
zero-24 - comment - 5 Jun 2014

@phproberto

And the same for the other calls

the first is fixed but i don't know the/a replacement for:

jQuery('#cloak$rand').append(...)
avatar fdesanto
fdesanto - comment - 11 Jun 2014

@zero-24
Solution:

document.getElementById('cloak$rand').innerHTML = document.getElementById('cloak$rand').innerHTML + ...

I tried on my dev site and works

avatar phproberto
phproberto - comment - 11 Jun 2014

Thanks @zero-24 for being so open to suggestions. :100:

To append things to an item html you can use += :

document.getElementById('cloak$rand').innerHTML += '<\/a>';
avatar zero-24
zero-24 - comment - 12 Jun 2014

Thanks @phproberto

It is done with zero-24@8b3d235

avatar laoneo
laoneo - comment - 9 Jul 2014

Worked perfect for me. Hope for a merge.

avatar Bakual
Bakual - comment - 9 Jul 2014

Travis fails. Can you fix that?

avatar laoneo
laoneo - comment - 9 Jul 2014

Can you tell us what failed as I couldn't figure out what caused the failed build.

avatar Bakual
Bakual - comment - 9 Jul 2014

The message according to Travis is this:

There was 1 failure:
1) JHtmlEmailTest::testCloak
Cloak e-mail with mailto link
Failed asserting that '<div id="cloak23364">JLIB_HTML_CLOAKING</div><script type='text/javascript'>
 <!--
 document.getElementById('cloak23364').innerHTML = '';
 var prefix = '&#109;a' + 'i&#108;' + '&#116;o';
 var path = 'hr' + 'ef' + '=';
 var addy23364 = '&#97;dm&#105;n' + '&#64;';
 addy23364 = addy23364 + 'j&#111;&#111;ml&#97;' + '&#46;' + '&#111;rg';
 document.getElementById('cloak23364').innerHTML += '<a ' + path + '\'' + prefix + ':' + addy23364 + '\'>';
 document.getElementById('cloak23364').innerHTML += 'addy23364';
 document.getElementById('cloak23364').innerHTML += '<\/a>';
 //-->\n </script>' contains "document.write('<a ' + path + '\'' + prefix + ':' + addy".
/home/travis/build/joomla/joomla-cms/tests/unit/suites/libraries/cms/html/JHtmlEmailTest.php:32

I guess one needs to adjust the test because the JavaScript output changed.

avatar zero-24
zero-24 - comment - 9 Jul 2014

Sorry @Bakual i don't know how to fix it.

avatar Bakual
Bakual - comment - 9 Jul 2014

Neither do I :smile:
Maybe @wilsonge can have a look if he has time?

avatar wilsonge
wilsonge - comment - 9 Jul 2014

Why have I suddenly become the unit test expert hides. Ummm I'll try and have a look but I'm so busy at the moment not sure when that will be. I don't think it will be that hard to do so it just depends when I get a free hour.

avatar wilsonge
wilsonge - comment - 9 Jul 2014

OK change this https://github.com/joomla/joomla-cms/blob/staging/tests/unit/suites/libraries/cms/html/JHtmlEmailTest.php#L30

from
$this->StringContains("document.write('<a ' + path + '\'' + prefix + ':' + addy"),
to
$this->StringContains(".innerHTML += '<a ' + path + '\'' + prefix + ':' + addy23364 + '\'>'"),

avatar Bakual
Bakual - comment - 9 Jul 2014

Why have I suddenly become the unit test expert

In german we have a saying "Among the blind the one-eyed is king" :smile:

avatar zero-24
zero-24 - comment - 9 Jul 2014
avatar losedk
losedk - comment - 9 Jul 2014

Tested. Works as expected!

avatar laoneo
laoneo - comment - 9 Jul 2014

Works for me too

avatar infograf768
infograf768 - comment - 10 Jul 2014

Travis still fails

avatar Bakual
Bakual - comment - 10 Jul 2014

Maybe try with $this->StringContains(".innerHTML += '<a ' + path + '\'' + prefix + ':' + addy"),
Since the number is random, we need to stop using this in the assertion and we can't use anything behind it.

avatar zero-24
zero-24 - comment - 10 Jul 2014
avatar Bakual Bakual - change - 10 Jul 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-07-10 19:13:41
avatar Bakual Bakual - close - 10 Jul 2014
avatar Bakual Bakual - close - 10 Jul 2014
avatar Bakual
Bakual - comment - 10 Jul 2014

Travis fine now. Thanks all!

avatar zero-24 zero-24 - head_ref_deleted - 10 Jul 2014
avatar laoneo
laoneo - comment - 11 Jul 2014

Great work. Will it be in the next Joomla release? Need to tell it my users as some are suffering from this bug. Will it be backported to Joomla 2.5?

avatar Bakual
Bakual - comment - 11 Jul 2014

It will be in the next release, yes.
We could backport it to 2.5 if someone wants to do a PR against the 2.5.x branch.

avatar wilsonge wilsonge - reference | - 11 Jul 14
avatar wilsonge
wilsonge - comment - 11 Jul 2014

I was just code reviewing this for a 2.5 backport and we've lost the open script tag in this PR. Yet we still have a close script tag. Seems dodgy.......

avatar losedk
losedk - comment - 11 Jul 2014

There is a opening script tag?

$replacement = '<div id="cloak' . $rand . '">' . JText::_('JLIB_HTML_CLOAKING') . '</div>' . "<script type='text/javascript'>";
avatar wilsonge
wilsonge - comment - 11 Jul 2014

facepalm

avatar losedk
losedk - comment - 11 Jul 2014

:D

avatar wilsonge
wilsonge - comment - 11 Jul 2014

#3885 backport PR if you want to test...

avatar infograf768
infograf768 - comment - 16 Jul 2014

Folks, I have issues with this: it breaks a link like:

été

The reason is that the text contains utf8 characters as everything is OK when using

ete

avatar Bakual
Bakual - comment - 16 Jul 2014

Doesn't look like related to this change. I've tried on an older test site and it also behaves like this there.

avatar infograf768
infograf768 - comment - 16 Jul 2014

I have reverted this and it works normally

I also have issues when using for example:

<p>ete@mysite.com</p>

reverting this PR solves all

avatar infograf768
infograf768 - comment - 16 Jul 2014

but yes, after reverting the mail with été is also broken

avatar mseymour
mseymour - comment - 16 Jul 2014

I noticed that the opening comment for all of the Javascript tags are not commented out (especially on the Travis build error listed earlier). Shouldn't they be commented?

avatar infograf768
infograf768 - comment - 17 Jul 2014

Merged #3914
remains an issue when adding an email to an image:
The link works fine but the image does not display anymore:

screen shot 2014-07-17 at 10 55 16

avatar infograf768
infograf768 - comment - 17 Jul 2014

I have a solution. Preparing patch

Add a Comment

Login with GitHub to post a comment