? ? Success

User tests: Successful: Unsuccessful:

avatar dgt41
dgt41
5 Jul 2016

Don't inject scripts in the document

Summary of Changes

Using the API for inline script

Testing Instructions

Create a new article and write an email address in it. save it and make a menu so you can see it in the front end.
Make sure the plugin email cloacking is enabled

Apply patch
Visit the page you should still see the email address
Disable the javascript in your browser and refresh the page. You should see the next message:
This email address is being protected from spambots. You need JavaScript enabled to view it.

Useful link: https://developer.mozilla.org/en-US/docs/Web/Events/readystatechange

avatar dgt41 dgt41 - open - 5 Jul 2016
avatar dgt41 dgt41 - change - 5 Jul 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 5 Jul 2016
Labels Added: ?
avatar dgt41 dgt41 - change - 5 Jul 2016
Title
use the API
Use the API for inline javascript on email clocking
avatar dgt41 dgt41 - change - 5 Jul 2016
Title
use the API
Use the API for inline javascript on email clocking
avatar dgt41 dgt41 - change - 5 Jul 2016
The description was changed
avatar dgt41 dgt41 - change - 5 Jul 2016
The description was changed
68cf6d6 5 Jul 2016 avatar dgt41 UT
avatar joomla-cms-bot joomla-cms-bot - change - 5 Jul 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 5 Jul 2016
Category Libraries
avatar brianteeman brianteeman - change - 5 Jul 2016
Labels
avatar dgt41 dgt41 - change - 5 Jul 2016
Labels
avatar yvesh yvesh - test_item - 5 Jul 2016 - Tested successfully
avatar yvesh
yvesh - comment - 5 Jul 2016

I have tested this item ✅ successfully on 351eb10

Works fine - thank you :)

screenshot 2016-07-05 19 58 59


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar brianteeman brianteeman - change - 5 Jul 2016
Category Libraries JavaScript
avatar brianteeman brianteeman - change - 5 Jul 2016
Labels
avatar dgt41 dgt41 - change - 5 Jul 2016
Labels
avatar joomla-cms-bot
joomla-cms-bot - comment - 5 Jul 2016

This PR has received new commits.

CC: @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar yvesh
yvesh - comment - 5 Jul 2016

@dgt41 wouldn't that be a good moment to switch to something better then random(1, 100000); ?

There is a chance (even when it is low) that, when there are many emails on one page that you get the same id and run into troubles or leak the email.

Better would be something like with uniqid(rand()) or openssl random for example.

avatar dgt41
dgt41 - comment - 5 Jul 2016

@yvesh good idea, which one shall we use here? also md5(the email addy) will work I think

avatar mbabker
mbabker - comment - 5 Jul 2016

Don't explicitly couple it to openssl. If you're worried about cryptographically secure randomness, use random_int() (already available to us because we have the random_compat polyfill). If you're not worried about it being cryptographically secure, either rand() or mt_rand() should be more than enough.

The main thing it looks like you're trying to avoid is duplicating use of an ID, there's no way around that by changing the random number generator; you'd still need a static state somewhere saying "yes this number has already been used".

avatar yvesh
yvesh - comment - 5 Jul 2016

uniqid(rand()) should be more then unique enough (not even sure if rand() is neceassary, this is only needed when something is generated at the same microsecond).

As an alternative you could use JUserHelper::genRandomPassword(10);

avatar joomla-cms-bot
joomla-cms-bot - comment - 5 Jul 2016

This PR has received new commits.

CC: @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar dgt41
dgt41 - comment - 5 Jul 2016

How about: // Random hash
$rand = md5($mail . rand(1, 100000));

avatar mbabker
mbabker - comment - 5 Jul 2016

That'd definitely eliminate the need to track which numbers are in use.

avatar yvesh
yvesh - comment - 5 Jul 2016

There is that one in a billion chance, that the same mail is printed multiple times on the page and the random number is the same. But the solution should be sufficient.

Hopefully md5 sums will be never so weak (or rainbow tables get that large), that even email addresses are cracked in seconds. ;)

avatar mbabker
mbabker - comment - 5 Jul 2016

You're not trying to cryptographically secure the addresses though. It's really just making it more troublesome for bots to scrape them off the generated HTML page. IMO it'd be better to use a different seed than the address you're trying to obfuscate, but in the long run all you're doing is inconveniencing some script kiddies crawling generated HTML.

avatar dgt41
dgt41 - comment - 5 Jul 2016

Reverse engineering open source code is a bit easier as you get to see the source code for free

avatar yvesh yvesh - test_item - 5 Jul 2016 - Tested successfully
avatar yvesh
yvesh - comment - 5 Jul 2016

I have tested this item ✅ successfully on 7b2bb6e

Works still fine - thank you @dgt41

screenshot 2016-07-05 20 31 48


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar joomla-cms-bot
joomla-cms-bot - comment - 5 Jul 2016

This PR has received new commits.

CC: @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar yvesh yvesh - test_item - 5 Jul 2016 - Tested successfully
avatar yvesh
yvesh - comment - 5 Jul 2016

I have tested this item ✅ successfully on 2df0786

Still working


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar Devportobello
Devportobello - comment - 6 Jul 2016

Is this working in an ajax context ? (with injection in dom and js execution) ? unable to give it a try actually ...
EDIT: this is not B/C, in an ajax context if you pick "content" actually you expect the inline JS with it... now its in head

avatar dgt41
dgt41 - comment - 6 Jul 2016

@Devportobello I guess we can still inject the script in the caller window with some magic to cover this case. can you point me to a module with an ajax call so I can provide the code needed?

avatar dgt41
dgt41 - comment - 6 Jul 2016

@Devportobello actually the script will not run if passed as data in the ajax call, so no B/C break here:
http://stackoverflow.com/questions/4619668/executing-script-inside-div-retrieved-by-ajax

avatar Devportobello
Devportobello - comment - 6 Jul 2016

@dgt41 you can execute JS with parseHTML : http://api.jquery.com/jQuery.parseHTML/

// call ajax then in done function with response as arg:
$('<div>').append( $.parseHTML( response, document, true ) ).find( '.item-page' );
avatar dgt41
dgt41 - comment - 6 Jul 2016

@Devportobello can you share a url used in the ajax call (I have an idea) ?

avatar Devportobello
Devportobello - comment - 6 Jul 2016

@dgt41 sended by mail to you

avatar joomla-cms-bot
joomla-cms-bot - comment - 6 Jul 2016

This PR has received new commits.

CC: @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar dgt41
dgt41 - comment - 6 Jul 2016

@Devportobello does my last commit cover the ajax part?

avatar Devportobello
Devportobello - comment - 6 Jul 2016

@dgt41 Nice try :), but in my case, i dont use "com_ajax" and i got 1 another custom tmpl "content", hmm diffcult to cover an ajax context, maybe with header

X-Requested-With : XMLHttpRequest
avatar joomla-cms-bot
joomla-cms-bot - comment - 6 Jul 2016

This PR has received new commits.

CC: @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar Devportobello
Devportobello - comment - 6 Jul 2016

Sound good, will give a try when enough time

863a9f2 6 Jul 2016 avatar dgt41 CS
avatar joomla-cms-bot
joomla-cms-bot - comment - 6 Jul 2016

This PR has received new commits.

CC: @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar killoltailored killoltailored - test_item - 11 Jul 2016 - Tested successfully
avatar killoltailored
killoltailored - comment - 11 Jul 2016

I have tested this item ✅ successfully on 863a9f2

I have tested it successfully
After giving value "False" to javascript.enabled in FireFox 47.0.1 getting message "This email address is being protected from spambots. You need JavaScript enabled to view it."
Test in Joomla Version: Joomla! 3.6.0-rc Release Candidate [ Noether ] 28-June-2016 20:34 GMT


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar AnishaTailored AnishaTailored - test_item - 11 Jul 2016 - Tested successfully
avatar AnishaTailored
AnishaTailored - comment - 11 Jul 2016

I have tested this item ✅ successfully on 863a9f2

Tested in Joomla! 3.6.0-rc2 [Noether] 6-July-2016 22:26 CET


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar hardiktailored
hardiktailored - comment - 11 Jul 2016

Yes, the default functionality to show message works fine after applying patch but what about content updated by AJAX call? Give me example code to check. How can I check AJAX response disabling JavaScript?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar Devportobello
Devportobello - comment - 11 Jul 2016

Just tested rapidly, seem not working on ajax context...
Here is a module to test this PR: https://github.com/Devportobello/joomla-attach-PR-11027

avatar hardiktailored hardiktailored - test_item - 12 Jul 2016 - Tested unsuccessfully
avatar hardiktailored
hardiktailored - comment - 12 Jul 2016

I have tested this item ? unsuccessfully on 863a9f2

Using AJAX to update content with email address in content seems not working. Shows message "This email address is being protected from spambots. You need JavaScript enabled to view it.", though JavaScript enabled.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar brianteeman brianteeman - change - 12 Jul 2016
Category JavaScript JavaScript Unit Tests
avatar brianteeman brianteeman - change - 12 Jul 2016
Labels
avatar rahultomar rahultomar - test_item - 13 Jul 2016 - Tested unsuccessfully
avatar rahultomar
rahultomar - comment - 13 Jul 2016

I have tested this item ? unsuccessfully on 863a9f2

Same thing is happening after apply patch and before patch. Please more detail for testing.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar joomla-cms-bot
joomla-cms-bot - comment - 13 Jul 2016

This PR has received new commits.

CC: @AnishaTailored, @hardiktailored, @killoltailored, @rahultomar, @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

e95e923 13 Jul 2016 avatar dgt41 fixes
avatar joomla-cms-bot
joomla-cms-bot - comment - 13 Jul 2016

This PR has received new commits.

CC: @AnishaTailored, @hardiktailored, @killoltailored, @rahultomar, @yvesh


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar joomla-cms-bot
joomla-cms-bot - comment - 13 Jul 2016

This PR has received new commits.

CC: @yvesh

avatar hardiktailored hardiktailored - test_item - 13 Jul 2016 - Tested successfully
avatar hardiktailored
hardiktailored - comment - 13 Jul 2016

I have tested this item ✅ successfully on e95e923

Context update by AJAX having email address in it, works now. I tested with module provided by @Devportobello


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar Devportobello
Devportobello - comment - 13 Jul 2016

Just noticed, there is no CS about inline JS in PHP ... http://joomla.github.io/coding-standards

avatar Devportobello Devportobello - test_item - 13 Jul 2016 - Tested successfully
avatar Devportobello
Devportobello - comment - 13 Jul 2016

I have tested this item ✅ successfully on e95e923

Work also in ajax context


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar brianteeman brianteeman - change - 13 Jul 2016
Status Pending Ready to Commit
Labels
avatar brianteeman
brianteeman - comment - 13 Jul 2016

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11027.

avatar joomla-cms-bot joomla-cms-bot - change - 13 Jul 2016
Labels Added: ?
avatar dgt41
dgt41 - comment - 13 Jul 2016

@Devportobello I proposed to PLT to switch to this format

JFactory::getDocument()->addScriptDeclaration(
<<<JS
//Script goes here with " and ' not needing escape
// Drawback you can't put vars like $this->id needs to be $id
JS
);

But is a lot of work to convert every inline script...

avatar roland-d roland-d - change - 16 Jul 2016
Milestone Added:
avatar joomla-cms-bot
joomla-cms-bot - comment - 16 Jul 2016

This PR has received new commits.

CC: @yvesh

avatar roland-d roland-d - change - 16 Jul 2016
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-07-16 17:51:58
Closed_By roland-d
avatar zero-24
zero-24 - comment - 16 Jul 2016
avatar joomla-cms-bot joomla-cms-bot - change - 16 Jul 2016
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment