I am not sure if this can be easily reproduced,
but it is clear that it is very much possible, it was reported in FLEXIcontent forums after upgrading to J2.5.25
Expected would be to have unique HTML tag ids
non-unique HTML tag ids
J2.5.25 / J3.3.4
emailcloak plugin triggered by FLEXIcontent component
-- Maybe instead of this code (class JHtmlEmail, function cloak()):
$rand = rand(1, 100000);
$replacement = '' ...
-- We can use:
static $rand = null;
if ($rand === null) $rand = rand(1, 100000); // initialize to random
$rand = $rand + 1; // now give unique IDs
$replacement = '' ...
Hello, will do during next couple of days
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
Hello
my suggested fix will guarantee a unique HTML tag ID (in some very rare cases it could happen),
but the problem is a little different
after looking at it more, this is what is happening:
i will need to find some time to test more, confirm the above, and suggest some fix for this, or someone else can fix it
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
Wouldn't that be a caching issue? I mean the most obvious way for the same content on the same page within the same component to have the same id would be for the component to cache the content and reuse it for the second appearance. Do you have any way of checking if that is the case? Say a page where it happens and you can check if the ids change when you reload the page? (A cache would be meant to save work across reloads and would reuse the same ids.)
Also I don't see the random number generator having any inputs for article id or the email link, so if it was by weak random number generator, it shouldn't make any difference if you have same content twice on the same page or not.
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
Hello,
not related to caching,
the plugin is not generating duplicate tag ids (although my above suggestion makes sure that it will never happen)
The problem is this:
-- we just print the article text twice, so the text/HTML is the same
to replicate the bug simply do (twice):
<?php echo $this->item->text; ?>
<?php echo $this->item->text; ?>
on second text you get: "This email address is being protected from spambots. You need JavaScript enabled to view it."
-- same for any other text on which you trigger the emailcloak plugin, it can not be used it places
-- result you cannot use the text in 2 places
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
I am not really familiar with the Joomla! API, but since you are using $this it looks to me like you are fetching the content once and then using it twice, meaning the content plugins would be ran only once. Essentially caching the content on the $this. The snippet is really too short to see the context, but the symptoms you describe would match. The solution would be to have a separate fetch for every use.
That said, I kind of agree that the script should be able to handle this, but since id attributes are supposed to be unique, that would really require switching to, for example, data-emailcloak attributes. Attribute values would encode the email link in obfuscated form and single script would then iterate thru all data-emailcloak attributes and do the proper replacements. This would actually be more efficient than the current system, but would require lots of work.
Hello
i am not sure that your suggestion is good,
triggering all content plugins twice on the long text (article descriptioni is usually a long text) in a category view with 100 articles is not performance wise
This comment was created with the J!Tracker Application at http://issues.joomla.org/.
Right. I think I am starting to understand your problem. Could you disable emailcloak for the content when requesting and then run it once for the combined content? This would not only solve the issue (if it is due to mismatch between fetches and uses), but also (slightly) improve performance.
Or you could simply add code that adds one to all emailcloak ids in the second use. Since the numbers in ids are random that should not be an issue. And since the id in the tag and script match, they would still match and work after adding one to the number. This would probably be easiest fix in your code.
That said, you probably have to do the "trigger twice", even if the issue is fixed for emailcloak, there is really no other way to make unknown content plugins users might be running in the future work correctly. Not saying problems are likely, but any content plugin that adds scripts can have issues when duplicated on a page. And you can't really predict if that is going to break anything.
Category | ⇒ | Plugins |
Just occurred to me... Would it be possible to add a call to .removeAttribute("id") to the JavaScript? If browsers do DOM correctly (no idea) that should work. In fact, unless browsers do some weird parallel tree building, there should be only one emailcloak id existing, briefly, at a time, as ids should, and the whole random number generation can be skipped for improved performance.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4383.
On second thought, validators would still complain about duplicate ids.
But maybe using class would be possible?
No, you need the randoms to deal with nested email links (which shouldn't exist, but probably do...)
Hello exactly the emailcloak plugin should insert 1 unique CSS class per email encountered instead of a unique ID, and the JS selector code should match all occurrences of the class
No, the idea was that if the DOM happens correctly, only one (or zero) of the many identical class (or id) instances ever exist in the DOM at any time. Basically the class would be removed by the coupled script before the next class instance can be added. And since only one instance of the class would ever exist at any time, the script would recover the correct link despite searching for a class with several instances in the source code.
I think it SHOULD work, and if it did, it would solve your issue, but... I am actually sick at home so I REALLY don't feel like testing it.
Labels |
Added:
?
|
Is this still an issue in joomla or is it specific to flexicontent?
Status | New | ⇒ | Information Required |
Hello, no it is not related to flexicontent,
also i made a correction to my initial posting,
the problem is not with the random number as i thought,
--> the problem is that we use HTML tag id in JS to find the email to cloak
so you can not print the cloaked email (twice):
(some users may want to output the article text in 2 places)
echo $article_text;
...
echo $article_text;
--> because you will get a duplicate HTML tag_id
a solution would be to change code to look for all occurences of a classname
I have tested this by creating two articles in one category. Each article has the same email address entered twice.
I then created a blog view to display these articles. This means that the cloaked email is present 4 times in total on the same page
All 4 email addresses have unique ID
See the screeenshots
@brianteeman
Yes this is ok. But if i understand @ggppdk right you can repoduce this by adding e.g. a content plugin that echo twice
<?php echo $this->item->text; ?>
<?php echo $this->item->text; ?>
So we have the same (prepared) text twice on the page. It is not the same (dublicate) email adress it is the same content IF you have the emails only the same email adress twice this will work ok and this is expected.
Is that a real world situation?
I also tested by publishing the article and the newsflash module on the
same page and the ID is still unique. Even with the article and two
identical newsflash modules the IS is still unique
On 14 January 2015 at 13:00, zero-24 notifications@github.com wrote:
@brianteeman https://github.com/brianteeman
Yes this is ok. But if i understand @ggppdk https://github.com/ggppdk
right you can repoduce this by adding e.g. a content plugin that echo twice<?php echo $this->item->text; ?>
<?php echo $this->item->text; ?>So we have the same (prepared) text twice on the page. It is not the same
(dublicate) email adress it is the same content [image: ] IF you
have the emails only the same email adress twice this will work ok and this
is expected.—
Reply to this email directly or view it on GitHub
#4383 (comment).
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/
I am just reluctant to introduce new code and therefore potential bugs just
because...
On 14 January 2015 at 13:10, zero-24 notifications@github.com wrote:
Is that a real world situation?
I don't know but this is a behavior there the ID is not unique maybe
@ggppdk https://github.com/ggppdk can explain in with more details / real
world examples.—
Reply to this email directly or view it on GitHub
#4383 (comment).
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/
please don't misunderstand me
i just "reported" or "identified" an issue, less common, yes i agree
it is not possible to use the cloacked email text in 2 places
-- a similar example -more common- example would be not being able to use an image twice in same page.
I don't say to fix or change something if it is not worth doing it, i can agree with Brian maybe this will not be supported or done in a future version
I could certainly provide a proper tested fix for this if i had more time,
or if it was a big problem for myself, i would certainly take time to make a pull request that utilizes a unique class name per email address instead of tag-id
Regards
it is not possible to use the cloacked email text in 2 places
But I showed that you can
On 14 January 2015 at 13:29, Georgios Papadakis notifications@github.com
wrote:
please don't misunderstand me
i just "reported" or "identified" an issue, less common, yes i agree
it is not possible to use the cloacked email text in 2 places
-- a similar example -more common- example would be not being able to use
an image twice in same page.I don't say to fix or change something if it is not worth doing it, i can
agree with Brian maybe this will not be supported or done in a future
versionI could certainly provide a proper tested fix for this if i had more time,
or if it was a big problem for myself, i would certainly take time to make
a pull request that utilizes a unique class name per email address instead
of tag-idRegards
—
Reply to this email directly or view it on GitHub
#4383 (comment).
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/
Yes they are
but if you print them twice, you get same HTML tag id, and the email cloaking no longer works
If @zero-24 simple example is accurate, then the only way to duplicate this issue is if you're outputting the same object multiple times as each object that processed through the onContentPrepare
event creates unique IDs. I think I'd close this as a known issue that won't be fixed; if you're outputting an object multiple times, you're going to get what is in that object multiple times.
but if you print them twice,
print them twice mean not twice with the editor but twice with code like:
<?php echo $this->item->text; ?>
<?php echo $this->item->text; ?>
if you're outputting an object multiple times, you're going to get what is in that object multiple times.
agree.
So we can accept this known issue:
if article text is used in 2 places, email cloaking will be work properly in 1 of them, and close this issue
Yes. If you really need to output the same data object twice, the only clean solution is to repeat all the steps that go into creating $this->item
(using ContentViewArticle as an example) using a new variable so that you are again fetching the raw data and processing that data through each of the plugins.
That could be a solution, but you can not control what content plugins do:
-- e.g. some other 3rd party content plugin could be incrementing a counter, or adding something into the DB
so in some cases we will create a different problem,
in general (for future coding) if we can avoid designing like that item text will only be displayed once, then better do it
--> i mean in the cases that this is possible !
e.g. for email cloaking it could have been done, if author of the code was aware of this while writting the code
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-01-14 13:54:28 |
Closed_By | ⇒ | brianteeman |
Closing based on the comments above
I have the same issue.
I created custom HTML module with text including email address and publish it in position that defined in my template twice (in header and in footer).
Next i open front-end page (home, for example) and both email cloaked with the same id and i can see first email at the top, but instead of second email at the bottom i see text "This email address is being protected from spambots. You need JavaScript enabled to view it." (of course Javascript is on in my browser).
You will need to create 2 different custom HTML modules (duplicating the contents). This should work.
thanks for your report here @ggppdk
Can you send your changes as pull request against the
staging
and2.5.x
branche?If you need help see here: http://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests
Thanks