Bug #36719
closedJavascript in header without script tags
100%
Description
I am using TYPO3 4.6.8 and TMENU_LAYERS. On some pages (in my case the one with the indexed_search plugin) the JavaScript code (starting with GLV_) is displayed on the page. A quick look in the source showed, that the <script> tags were missing around the TMENU_LAYERS JS code. But only, when the cache is active. A &no_cache=1 in the url and the display looked OK.
In TYPO3 4.5.15 everything worked fine.
I did some research and found that: http://bugs.typo3.org/bug_view_advanced_page.php?bug_id=18513
And I think I found the error in the TYPO3 core:
In tslib_fe::INTincScript() disappeared the line
$this->JSCode = $this->additionalHeaderData['JSCode'];
(compared 4.5.15 with 4.6.8). I cannot see any meaning or intention behind that change, so I suppose this is the bug.
Files
Updated by Sean Fulton over 12 years ago
REPOST:
We recently tried to upgrade a site from 4.5 to 4.6. We found that on pages with a tt_news container, a big chunk of navigation code gets ripped out of the page once it is cached, causing the pull-down navigational elements to appear on the upper-left corner of the screen.
This happens with tt_news 3.0.1 to 3.2.1 and only in Typo3 4.6. The menu elements appear when the cache is cleared, but on reload, the code is missing. What's interesting is that it appears the code is stored in the datase with the cached copy of the page, but is not sent to the browser on reload.
One of our developers reported that if you force the browser to clear its cache, the code will re-appear, but we have not been able to verify that in all browsers.
This is what appears after you clear the cache:
<script type="text/javascript">
/*<![CDATA[*/
/*]]>*/
</script>
This is what appears after you reload the page (ie, once it has been cached).
<script type="text/javascript">
/*<![CDATA[*/
/*]]>*/
</script>
Updated by Rafal Likus over 12 years ago
I have the same effect with JSmenu.
This is with properly generated page:
<script type="text/javascript" src="t3lib/jsfunc.menu.js"></script> <script type="text/javascript"> /*<![CDATA[*/ <!-- var JSmenub2df5 = new JSmenu(1,'JSmenub2df5Form');
And this after reload:
<script type="text/javascript" src="t3lib/jsfunc.menu.js"></script> var JSmenub2df5 = new JSmenu(1,'JSmenub2df5Form');
Adding mentioned line to typo3\sysext\cms\tslib\class.tslib_fe.php solved problem.
Updated by Jonas Götze over 12 years ago
Hi,
same for me after update from 4.5.15 to 4.7.1, so this issue still exists in 4.7. Adding the line solved it for me too.
Regards
Updated by Stefan Galinski over 12 years ago
Can you please open a review request with the one-liner? It's really easy... :-)
Updated by Kurt Gusbeth about 12 years ago
- Target version set to 4.7.5
I have the same promblem with Typo3 4.7.4.
I can confirm it for "JSMENU" too.
Updated by Kurt Gusbeth about 12 years ago
Note: the missing line is in the file typo3/sysext/cms/tslib/class.tslib_fe.php
Updated by Christian Geiselmann about 12 years ago
I had the same issue with Typo3 4.7.1 after I started mounting frontend user login elements on several pages of my site (using the felogin extension).
Adding the mentioned line of code helped in my case, too.
Here some details for people facing the same problem:
In the class.tslib_fe.php in Typo3 4.5.15 the line in question is line 3217
In my Typo3 4.7.1 this became line 3200, after I had added it.
Or, in other words: replace
$this->additionalCSS = $this->config['INTincScript_ext']['additionalCSS'];
$this->JSImgCode = $this->additionalHeaderData['JSImgCode'];
by
$this->additionalCSS = $this->config['INTincScript_ext']['additionalCSS'];
$this->JSCode = $this->additionalHeaderData['JSCode'];
$this->JSImgCode = $this->additionalHeaderData['JSImgCode'];
And enjoy!
Christian Geiselmann
Updated by Christian Geiselmann over 11 years ago
Hi Everybody,
I am coming back to this issue - and still unsolved Typo3 4.7 core bug - since after a core update (from 4.7.1 to 4.7.7) the same issue appeared on our site. - Funnily I did not remember that I had solved it, months ago, myself, and now asked our chief programmer to find out what the heck is this strange javascript code on top of pages with login forms. He googled the topic for a while and finally stumbled upon this bug report, including my own comment and advice. He solved the issue the same way I did months ago. But apparently, this will need to be done after every core update.
What could I possibly do to motivate the Typo3 community to fix the bug at its source?
Regards,
Christian Geiselmann
Updated by Wouter Wolters over 11 years ago
Hi Christian,
There are several things you can do. You have already a working solution yourself.
So the best way is to push a patch to our reviewing system "Gerrit".
A guideline can be founr here: http://wiki.typo3.org/Contribution_Walkthrough_with_CommandLine
If this is not possible due to any reason, can you provide a patch file of the changes you made for the working solution?
Or send the complete changed file?
Greetz Wouter
Updated by Kurt Gusbeth over 11 years ago
- File bug_36719.diff bug_36719.diff added
- Target version deleted (
4.7.5)
I have created a patch-file. Maybe this helps too.
Updated by Kurt Gusbeth over 11 years ago
- File bug_36719.diff bug_36719.diff added
Maybe it is better to add an if-statement too...
Updated by Michael Stucki over 11 years ago
Started investigation on it. The change was removed in 4e53925db0933d58fe40a2397dd246219c3d55f7.
Updated by Ernesto Baschny over 11 years ago
- Status changed from New to Accepted
- Priority changed from Should have to Must have
Happens that TSFE->JSCode was "deprecated since 3.5" but was still being used by the core (exactly in GMENU_LAYERS and TMENU_LAYERS).
So it was removed in 4.6 without adapting the code of GMENU_LAYERS and TMENU_LAYERS.
Two solutions: Either put JSCode back in (also 4.7, 6.0, 6.1) and postpone the deprecation to a time when TMENU_LAYERS and GMENU_LAYERS are rewritten. Or do both at the same time.
Or an intermediate solution: Just put it back in the already released 4.6, 4.7, 6.0 and remove and rewrite the menu classes for 6.1.
Updated by Gerrit Code Review over 11 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/18948
Updated by Gerrit Code Review over 11 years ago
Patch set 1 for branch TYPO3_4-6 has been pushed to the review server.
It is available at https://review.typo3.org/18949
Updated by Ernesto Baschny over 11 years ago
I've added the reversing code as a review request for 4.6 and master. Please check out if this solves your problem.
Updated by Gerrit Code Review over 11 years ago
Patch set 1 for branch TYPO3_6-0 has been pushed to the review server.
It is available at https://review.typo3.org/19262
Updated by Michael Stucki over 11 years ago
I don't think we should add the deprecated code again. How about this approach? https://review.typo3.org/#/c/19262/
Btw. the fix is not needed in master anymore, since "statictemplates" have been removed entirely.
Updated by Michael Stucki over 11 years ago
- Status changed from Under Review to Needs Feedback
- Assignee set to Ernesto Baschny
Updated by Gerrit Code Review over 11 years ago
- Status changed from Needs Feedback to Under Review
Patch set 1 for branch TYPO3_4-7 has been pushed to the review server.
It is available at https://review.typo3.org/19263
Updated by Gerrit Code Review over 11 years ago
Patch set 1 for branch TYPO3_4-6 has been pushed to the review server.
It is available at https://review.typo3.org/19264
Updated by Gerrit Code Review over 11 years ago
Patch set 1 for branch TYPO3_4-5 has been pushed to the review server.
It is available at https://review.typo3.org/19265
Updated by Michael Stucki over 11 years ago
See https://review.typo3.org/#/q/project:TYPO3v4/Core+topic:36719,n,z for an overview.
Updated by Gerrit Code Review over 11 years ago
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19266
Updated by Gerrit Code Review over 11 years ago
Patch set 2 for branch TYPO3_6-0 has been pushed to the review server.
It is available at https://review.typo3.org/19262
Updated by Gerrit Code Review over 11 years ago
Patch set 3 for branch TYPO3_6-0 has been pushed to the review server.
It is available at https://review.typo3.org/19262
Updated by Gerrit Code Review over 11 years ago
Patch set 2 for branch TYPO3_4-7 has been pushed to the review server.
It is available at https://review.typo3.org/19263
Updated by Gerrit Code Review over 11 years ago
Patch set 2 for branch TYPO3_4-6 has been pushed to the review server.
It is available at https://review.typo3.org/19264
Updated by Gerrit Code Review over 11 years ago
Patch set 2 for branch TYPO3_4-5 has been pushed to the review server.
It is available at https://review.typo3.org/19265
Updated by Christian Kuhn over 11 years ago
how to reproduce
take a 4.7 instance
install statictemplates
install indexed_search
create a page "test"
create sub page 'main 1'
create sub page in 'main 1' called 'sub 1'
backend -> template -> info/modify -> chose "template green" in drop down -> "create template for a new site"
place content element "indexed search" on page "main 1"
view page in frontend in different (no be log in) browser
reload page once -> you should see some garbage top left (this is JS code of the gmenu_layer)
apply patch from https://review.typo3.org/#/c/19263/
clear cache
call page twice again -> no more garbage and the menu is working (showing sub page 1 on hover)
Updated by Michael Stucki over 11 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 978d0bc8c5f606c060aab8b0870bbe997c2f8352.
Updated by Christian Geiselmann over 11 years ago
Dear all,
// Attention: this posting was based on the mistaken assumption that inserted Javascript code is a bug per se. Ernesto, who answered the posting, informed my about the mistake. //
I am back again with the same problem, although I thought it to be solved.
This is the situation:
I am running a Typo3 4.7.x site. Months ago I had the problem with a fragment of javascript code (such as GLV_curLayerWidth["topnav1x"]=0; GLV_curLayerHeight["topnav1x"]=0;...
) appearing in the html output of my pages. (See my earlier postings.) I solved this by adding the line
$this->JSCode = $this->additionalHeaderData['JSCode'];
into the file typo3\sysext\cms\tslib\class.tslib_fe.php, at the place discussed above.
But now the problem appeared again. In the html output I currently receive the following:
{{{
<script type="text/javascript">/*<![CDATA[*/ <!-- GLV_curLayerWidth["273ecc"]=0; GLV_curLayerHeight["273ecc"]=0; GLV_curLayerX["273ecc"]=0; GLV_curLayerY["273ecc"]=0; GLV_menuOn["273ecc"] = null; GLV_gap["273ecc"]=50; GLV_currentLayer["273ecc"] = null; GLV_currentROitem["273ecc"] = null; GLV_hasBeenOver["273ecc"]=0; GLV_doReset["273ecc"]=false; GLV_lastKey["273ecc"] = "Menu273ecc22"; GLV_onlyOnLoad["273ecc"] = 0; GLV_dontHideOnMouseUp["273ecc"] = 0; GLV_dontFollowMouse["273ecc"] = 0; GLV_date = new Date(); GLV_timeout["273ecc"] = GLV_date.getTime(); GLV_timeoutRef["273ecc"] = 70; GLV_menuXY["273ecc"] = new Array(); GLV_menuXY["273ecc"]["Menu273ecc0"] = new Array(0,0,"itemIDf1483fbc58","anchorIDf1483fbc58"); GLV_menuXY["273ecc"]["Menu273ecc1"] = new Array(0,0,"itemID934c44513f","anchorID934c44513f"); GLV_menuXY["273ecc"]["Menu273ecc2"] = new Array(0,0,"itemID9770a27bdf","anchorID9770a27bdf"); GLV_menuXY["273ecc"]["Menu273ecc3"] = new Array(0,0,"itemID041510fa3d","anchorID041510fa3d"); GLV_menuXY["273ecc"]["Menu273ecc4"] = new Array(0,0,"itemIDe5569a0d0b","anchorIDe5569a0d0b"); GLV_menuXY["273ecc"]["Menu273ecc5"] = new Array(0,0,"itemIDf52d41bddb","anchorIDf52d41bddb"); GLV_menuXY["273ecc"]["Menu273ecc6"] = new Array(0,0,"itemIDb75a4b3f56","anchorIDb75a4b3f56"); GLV_menuXY["273ecc"]["Menu273ecc7"] = new Array(0,0,"itemID171ed94b19","anchorID171ed94b19"); GLV_menuXY["273ecc"]["Menu273ecc8"] = new Array(0,0,"itemIDfd5c06630e","anchorIDfd5c06630e"); GLV_menuXY["273ecc"]["Menu273ecc9"] = new Array(0,0,"itemID068343a7cf","anchorID068343a7cf"); GLV_menuXY["273ecc"]["Menu273ecc10"] = new Array(0,0,"itemID9ef36915ea","anchorID9ef36915ea"); GLV_menuXY["273ecc"]["Menu273ecc11"] = new Array(0,0,"itemID49369830c9","anchorID49369830c9"); GLV_menuXY["273ecc"]["Menu273ecc12"] = new Array(0,0,"itemID7eb2c8b27d","anchorID7eb2c8b27d"); GLV_menuXY["273ecc"]["Menu273ecc13"] = new Array(0,0,"itemID47190634c7","anchorID47190634c7"); GLV_menuXY["273ecc"]["Menu273ecc14"] = new Array(0,0,"itemIDe6e2394abd","anchorIDe6e2394abd"); GLV_menuXY["273ecc"]["Menu273ecc15"] = new Array(0,0,"itemIDbab9ac8b32","anchorIDbab9ac8b32"); GLV_menuXY["273ecc"]["Menu273ecc16"] = new Array(0,0,"itemIDb8cdb919d9","anchorIDb8cdb919d9"); GLV_menuXY["273ecc"]["Menu273ecc17"] = new Array(0,0,"itemID135d21ea6d","anchorID135d21ea6d"); GLV_menuXY["273ecc"]["Menu273ecc18"] = new Array(0,0,"itemID0130d35b2f","anchorID0130d35b2f"); GLV_menuXY["273ecc"]["Menu273ecc19"] = new Array(0,0,"itemIDdffb3094d5","anchorIDdffb3094d5"); GLV_menuXY["273ecc"]["Menu273ecc20"] = new Array(0,0,"itemID0f6e40d35e","anchorID0f6e40d35e"); GLV_menuXY["273ecc"]["Menu273ecc21"] = new Array(0,0,"itemIDc3a6745b66","anchorIDc3a6745b66"); GLV_menuXY["273ecc"]["Menu273ecc22"] = new Array(0,0,"itemID61cc671107","anchorID61cc671107"); function GL273ecc_getMouse(e) { if (GLV_menuOn["273ecc"]!=null && !GLV_dontFollowMouse["273ecc"]){ } GL_mouseMoveEvaluate("273ecc"); } function GL273ecc_hideCode() { GL_getObjCss("Menu273ecc3").visibility = "hidden"; GL_getObjCss("Menu273ecc4").visibility = "hidden"; GL_getObjCss("Menu273ecc5").visibility = "hidden"; GL_getObjCss("Menu273ecc6").visibility = "hidden"; GL_getObjCss("Menu273ecc7").visibility = "hidden"; GL_getObjCss("Menu273ecc8").visibility = "hidden"; GL_getObjCss("Menu273ecc9").visibility = "hidden"; GL_getObjCss("Menu273ecc11").visibility = "hidden"; GL_getObjCss("Menu273ecc13").visibility = "hidden"; GL_getObjCss("Menu273ecc17").visibility = "hidden"; GL_getObjCss("Menu273ecc19").visibility = "hidden"; GL_getObjCss("Menu273ecc22").visibility = "hidden"; } function GL273ecc_doTop(WMid,id) { var parentObject = GL_getObj(GLV_menuXY[WMid][id][2]); var TI_width = parentObject.width; var TI_height = parentObject.height; var anchorObj = GL_getObj(GLV_menuXY[WMid][id][3]); var TI_x = anchorObj.x; var TI_y = anchorObj.y; GLV_menuOn["273ecc"].left = (TI_x+0)+"px"; GLV_menuOn["273ecc"].top = (TI_y+17)+"px"; } function GL273ecc_restoreMenu() { } function GL273ecc_resetSubMenus() { var resetSubMenu=1; return resetSubMenu; } GLV_timeout_pointers[GLV_timeout_count] = "273ecc"; GLV_timeout_count++; // --> /*]]>*/</script>
}}}
Based on my positive experience with the earlier bugfixes, I checked again the class.tslib_fe.php, and found that - perhaps due to an update to 4.7.12 weeks ago - the line of code in question was missing, and so I added it once more.
Beforehand, I also had checked for the changes described in https://review.typo3.org/19263. I found that the additions were all implemented in the 4.7.12 core-files, so I had nothing to change here.
However, this time, it seems the bugfix has no effect. My pages still do not load in IE8, and still the piece of code is visible in the html output.
What I am doing now is updating my core to 4.7.14. I hope this has a positive effect...
Or do you have better suggestions?
Updated by Christian Geiselmann over 11 years ago
Update:
A)
I upgraded to Typo3 4.7.14, and I added the line of code to the class.tslib_fe.php, but it did not help. The piece of code appears in the html output anyway. (Of course, cache has been emptied).
Additionally I set "do not cache" for one of the affected pages. I also set "do not include in search" for this page, since from various postings I understand that indexed_search seems to play a role here. But anyway, the piece of code is in the output.
Updated by Ernesto Baschny over 11 years ago
- Status changed from Resolved to Needs Feedback
The "line of code" you mention is not required since 4.7.12, since the GMENU_LAYER and and TMENU_LAYER were adapted to use the new API. See: https://review.typo3.org/#/c/19264/
In your above quote, why do you think this is "lengthy rubbish"? This seems like a normal and also enclosed with proper <script> tag.
Do you have any extension which might be adding JS through the deprecated "TSFE->JSCode" property?
Updated by Christian Geiselmann over 11 years ago
Hello Ernesto,
Thank you for answering so quickly. My statement "lengthy rubbish" was obviously triggered by lack of understanding, I admit. (I am not the real programmer in our project...) Based on the past experiences (see postings above) I (obviously mistakenly) thought that such code should not get displayed at all; I now learned from your answer that it is expected to be there, in certain circumstances, and the problem in earlier situations was that a closing tag was missing.
As for extensions that may use "TSEF->JSCode": It is very well possible that there is such an extension. I think, my programmer suspects picture gallery extension we use (lightbox gallery)...
Following your advice concerning 4.7.12, I will remove now the additional line of code I inserted to class.tslib_fe.php.
Thanks,
kind regards,
Christian
Updated by Ernesto Baschny over 11 years ago
- Status changed from Needs Feedback to Resolved
So switching back issue to "Resolved". If you have any other issue in this regard that you might consider a bug, don't hesitate to open up a new issue (and relate it to this one, if you feel its related).
Thanks for your help and feedback, we appreciate your effort to try to improve TYPO3 CMS together with us!
Updated by Kurt Gusbeth about 10 years ago
As info:
same problem in Typo3 6.2.4. The missing line is there in the file
/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
in the function INTincScript.
Updated by Kurt Gusbeth about 10 years ago
This is not a Typo3-bug. It is a bug of statictemplates.
It was adapted to the new API in Typo3 4.7.17, but statictemplates 6.0.0 is not adapted to the new API! Take a look at
statictemplates/Classes/ContentObjectMenu/Menu/TextMenuLayersContentObject.php
Search for JSCode ! It is still there.
Here at forge is no project for the statictemplates-extension.
So where can I commit this bug?
Updated by Kurt Gusbeth almost 10 years ago
Because I still have the problem, here the solution for statictemplates 6.0.0:
open the file statictemplates/Classes/ContentObjectMenu/Menu/TextMenuLayersContentObject.php
and replace all $GLOBALS['TSFE']->JSCode with $GLOBALS['TSFE']->additionalJavaScript['gmenu_layer_code'].
Updated by Sebastien Michel about 9 years ago
@Kurt: +1 for the patch published on Note 39 on statictemplates
(Tested on Typo3 6.2.15 & statictemplates 6.0.0)