File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/**
2- * Conditionally included if framing is not allowed
2+ * Conditionally included if framing is not allowed.
3+ * @return {void }
34 */
4- if ( self === top ) {
5- var styleElement = document . getElementById ( 'cfs-style' ) ;
6- // check if styleElement has already been removed
7- // to avoid frequently reported js error
8- if ( typeof ( styleElement ) !== 'undefined' && styleElement !== null ) {
9- styleElement . parentNode . removeChild ( styleElement ) ;
5+ const crossFramingProtection = ( ) => {
6+ if ( window . allowThirdPartyFraming ) {
7+ return ;
108 }
11- } else {
12- top . location = self . location ;
13- }
9+
10+ if ( window . self !== window . top ) {
11+ window . top . location = window . self . location ;
12+ return ;
13+ }
14+
15+ const styleElement = document . getElementById ( 'cfs-style' ) ;
16+ // check if styleElement has already been removed to avoid frequently reported js error
17+ if ( typeof ( styleElement ) === 'undefined' || styleElement === null ) {
18+ return ;
19+ }
20+
21+ styleElement . parentNode . removeChild ( styleElement ) ;
22+ } ;
23+
24+ crossFramingProtection ( ) ;
Original file line number Diff line number Diff line change @@ -140,17 +140,7 @@ private function addDefaultScripts(): void
140140 $ this ->scripts ->addFile ('vendor/jquery/jquery.validate.js ' );
141141 $ this ->scripts ->addFile ('vendor/jquery/jquery-ui-timepicker-addon.js ' );
142142 $ this ->scripts ->addFile ('menu_resizer.js ' );
143-
144- // Cross-framing protection
145- // At this point browser settings are not merged
146- // this is good that we only use file configuration for this protection
147- if ($ GLOBALS ['cfg ' ]['AllowThirdPartyFraming ' ] === false ) {
148- $ this ->scripts ->addFile ('cross_framing_protection.js ' );
149- }
150-
151- // Here would not be a good place to add CodeMirror because
152- // the user preferences have not been merged at this point
153-
143+ $ this ->scripts ->addFile ('cross_framing_protection.js ' );
154144 $ this ->scripts ->addFile ('messages.php ' , ['l ' => $ GLOBALS ['lang ' ]]);
155145 $ this ->scripts ->addFile ('config.js ' );
156146 $ this ->scripts ->addFile ('doclinks.js ' );
Original file line number Diff line number Diff line change 44 <meta charset =" utf-8" >
55 <meta name =" viewport" content =" width=device-width, initial-scale=1" >
66 <meta name =" referrer" content =" no-referrer" >
7- <meta name = " robots " content = " noindex,nofollow " >
7+ <script > window . allowThirdPartyFraming = {{ allow_third_party_framing == ' sameorigin ' ? ' "sameorigin" ' : ( allow_third_party_framing ? ' 1 ' : ' 0 ' ) }};</ script >
88 {% if not allow_third_party_framing -%}
99 <style id =" cfs-style" >html {display : none ;}</style >
1010 {%- endif %}
You can’t perform that action at this time.
0 commit comments