Skip to content

Commit f15c791

Browse files
authored
Merge pull request #6335 from WoltLab/6.2-global-templates-unsafe
Refactor global templates
2 parents cd4b430 + d3bce73 commit f15c791

28 files changed

Lines changed: 132 additions & 132 deletions

com.woltlab.wcf/templates/__menu.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{event name='menuBefore'}
44

55
{foreach from=$menuItemNodeList item=menuItemNode}
6-
<li class="{if $menuItemNode->isActiveNode()}active{/if}{if $menuItemNode->hasChildren()} boxMenuHasChildren{/if}" data-identifier="{@$menuItemNode->identifier}">
6+
<li class="{if $menuItemNode->isActiveNode()}active{/if}{if $menuItemNode->hasChildren()} boxMenuHasChildren{/if}" data-identifier="{$menuItemNode->identifier}">
77
<a {anchorAttributes url=$menuItemNode->getURL() appendClassname=false} class="boxMenuLink"{if $menuItemNode->isActiveNode()} aria-current="page"{/if}>
88
<span class="boxMenuLinkTitle">{$menuItemNode->getTitle()}</span>
99
{if $menuItemNode->getOutstandingItems() > 0}
@@ -14,10 +14,10 @@
1414
{/if}
1515
</a>
1616

17-
{if $menuItemNode->hasChildren()}<ol class="boxMenuDepth{@$menuItemNode->getDepth()}">{else}</li>{/if}
17+
{if $menuItemNode->hasChildren()}<ol class="boxMenuDepth{$menuItemNode->getDepth()}">{else}</li>{/if}
1818

1919
{if !$menuItemNode->hasChildren() && $menuItemNode->isLastSibling()}
20-
{@"</ol></li>"|str_repeat:$menuItemNode->getOpenParentNodes()}
20+
{unsafe:"</ol></li>"|str_repeat:$menuItemNode->getOpenParentNodes()}
2121
{/if}
2222
{/foreach}
2323

com.woltlab.wcf/templates/authFlowFooter.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
<!-- {$__wcf->getRequestNonce('JAVASCRIPT_RELOCATE_POSITION')} -->
2323

24-
{@FOOTER_CODE}
24+
{unsafe:FOOTER_CODE}
2525

2626
<span id="bottom"></span>
2727

com.woltlab.wcf/templates/authFlowHeader.tpl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{/if}
1010
{/if}
1111

12-
<title>{if $pageTitle}{@$pageTitle} - {/if}{PAGE_TITLE|phrase}</title>
12+
<title>{if $pageTitle}{unsafe:$pageTitle} - {/if}{PAGE_TITLE|phrase}</title>
1313

1414
{include file='headInclude'}
1515

@@ -18,14 +18,14 @@
1818
{/if}
1919

2020
{if !$headContent|empty}
21-
{@$headContent}
21+
{unsafe:$headContent}
2222
{/if}
2323
</head>
2424

2525
<body id="tpl_{$templateNameApplication}_{$templateName}"
2626
itemscope itemtype="http://schema.org/WebPage"{if !$canonicalURL|empty} itemid="{$canonicalURL}"{/if}
27-
data-template="{$templateName}" data-application="{$templateNameApplication}"{if $__wcf->getActivePage() != null} data-page-id="{@$__wcf->getActivePage()->pageID}" data-page-identifier="{$__wcf->getActivePage()->identifier}"{/if}
28-
{if !$__pageDataAttributes|empty}{@$__pageDataAttributes}{/if}
27+
data-template="{$templateName}" data-application="{$templateNameApplication}"{if $__wcf->getActivePage() != null} data-page-id="{$__wcf->getActivePage()->pageID}" data-page-identifier="{$__wcf->getActivePage()->identifier}"{/if}
28+
{if !$__pageDataAttributes|empty}{unsafe:$__pageDataAttributes}{/if}
2929
class="authFlow{if $__wcf->getActivePage() != null && $__wcf->getActivePage()->cssClassName} {$__wcf->getActivePage()->cssClassName}{/if}{if !$__pageCssClassName|empty} {$__pageCssClassName}{/if}">
3030

3131
<span id="top"></span>
@@ -49,12 +49,12 @@
4949
</header>
5050
</div>
5151

52-
<section id="main" class="main" role="main"{if !$__mainItemScope|empty} {@$__mainItemScope}{/if}>
52+
<section id="main" class="main" role="main"{if !$__mainItemScope|empty} {unsafe:$__mainItemScope}{/if}>
5353
<div class="layoutBoundary">
5454
<div id="content" class="content">
5555
{if $__disableContentHeader|empty}
5656
{if !$contentHeader|empty}
57-
{@$contentHeader}
57+
{unsafe:$contentHeader}
5858
{else}
5959
{if $contentTitle|empty}
6060
{if $__wcf->isLandingPage() && USE_PAGE_TITLE_ON_LANDING_PAGE}
@@ -68,8 +68,8 @@
6868
{if !$contentTitle|empty}
6969
<header class="contentHeader">
7070
<div class="contentHeaderTitle">
71-
<h1 class="contentTitle">{@$contentTitle}{if !$contentTitleBadge|empty} {@$contentTitleBadge}{/if}</h1>
72-
{if !$contentDescription|empty}<p class="contentHeaderDescription">{@$contentDescription}</p>{/if}
71+
<h1 class="contentTitle">{unsafe:$contentTitle}{if !$contentTitleBadge|empty} {unsafe:$contentTitleBadge}{/if}</h1>
72+
{if !$contentDescription|empty}<p class="contentHeaderDescription">{unsafe:$contentDescription}</p>{/if}
7373
</div>
7474
</header>
7575
{/if}

com.woltlab.wcf/templates/authFlowRedirect.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{capture assign='pageTitle'}{lang}wcf.page.redirect.title{/lang}{/capture}
22

33
{capture assign='headContent'}
4-
<meta http-equiv="refresh" content="{if $wait|isset}{@$wait}{else}10{/if};URL={$url}">
4+
<meta http-equiv="refresh" content="{if $wait|isset}{$wait}{else}10{/if};URL={$url}">
55
{/capture}
66

77
{include file='authFlowHeader'}
88

9-
<div class="{if !$status|empty}{@$status}{else}success{/if}">
10-
<p>{@$message}</p>
9+
<div class="{if !$status|empty}{$status}{else}success{/if}">
10+
<p>{unsafe:$message}</p>
1111
<br>
1212
<p><a href="{$url}">{lang}wcf.page.redirect.url{/lang}</a></p>
1313
</div>

com.woltlab.wcf/templates/breadcrumbs.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<span class="breadcrumbs__title"{if $__microdata} itemprop="name"{/if}>{$breadcrumb->getLabel()}</span>
1818
</a>
1919
{if $__microdata}
20-
<meta itemprop="position" content="{@$__breadcrumbPos}">
20+
<meta itemprop="position" content="{$__breadcrumbPos}">
2121
{assign var='__breadcrumbPos' value=$__breadcrumbPos+1}
2222
{/if}
2323
</li>

com.woltlab.wcf/templates/error.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{if $exception !== null}
1313
<!--
1414
{* A comment may not contain double dashes. *}
15-
{@'--'|str_replace:'- -':$exception}
15+
{unsafe:'--'|str_replace:'- -':$exception}
1616
-->
1717
{/if}
1818
{/if}
@@ -21,7 +21,7 @@
2121
<div class="box64 userException">
2222
{icon size=64 name='circle-exclamation'}
2323
<p class="userExceptionMessage">
24-
{@$message}
24+
{unsafe:$message}
2525
</p>
2626
</div>
2727
</div>

com.woltlab.wcf/templates/footer.tpl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
<div class="boxContainer">
66
{content}
77
{if !$boxesContentBottom|empty}
8-
{@$boxesContentBottom}
8+
{unsafe:$boxesContentBottom}
99
{/if}
1010

1111
{foreach from=$__wcf->getBoxHandler()->getBoxes('contentBottom') item=box}
12-
{@$box->render()}
12+
{unsafe:$box->render()}
1313
{/foreach}
1414
{/content}
1515
</div>
1616
</div>
1717
{/hascontent}
1818

1919
{if MODULE_WCF_AD && $__disableAds|empty}
20-
{@$__wcf->getAdHandler()->getAds('com.woltlab.wcf.footer.content')}
20+
{unsafe:$__wcf->getAdHandler()->getAds('com.woltlab.wcf.footer.content')}
2121
{/if}
2222
</div>
2323

2424
{hascontent}
2525
<aside class="sidebar boxesSidebarRight" aria-label="{lang}wcf.page.sidebar.right{/lang}">
2626
<div class="boxContainer">
27-
{content}{@$__sidebarRightContent}{/content}
27+
{content}{unsafe:$__sidebarRightContent}{/content}
2828
</div>
2929
</aside>
3030
{/hascontent}
@@ -36,11 +36,11 @@
3636
<div class="boxContainer">
3737
{content}
3838
{if !$boxesBottom|empty}
39-
{@$boxesBottom}
39+
{unsafe:$boxesBottom}
4040
{/if}
4141

4242
{foreach from=$__wcf->getBoxHandler()->getBoxes('bottom') item=box}
43-
{@$box->render()}
43+
{unsafe:$box->render()}
4444
{/foreach}
4545
{/content}
4646
</div>
@@ -53,11 +53,11 @@
5353
<div class="boxContainer">
5454
{content}
5555
{if !$footerBoxes|empty}
56-
{@$footerBoxes}
56+
{unsafe:$footerBoxes}
5757
{/if}
5858

5959
{foreach from=$__wcf->getBoxHandler()->getBoxes('footerBoxes') item=box}
60-
{@$box->render()}
60+
{unsafe:$box->render()}
6161
{/foreach}
6262
{/content}
6363
</div>
@@ -84,7 +84,7 @@
8484

8585
<!-- {$__wcf->getRequestNonce('JAVASCRIPT_RELOCATE_POSITION')} -->
8686

87-
{@FOOTER_CODE}
87+
{unsafe:FOOTER_CODE}
8888

8989
<span id="bottom"></span>
9090

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<meta name="viewport" content="width=device-width, initial-scale=1">
22
<meta name="format-detection" content="telephone=no">
33
{include file='headIncludeRobotsMetaTag'}
4-
{implode from=$__wcf->getMetaTagHandler() item=__metaTag glue="\n"}{@$__metaTag}{/implode}
4+
{implode from=$__wcf->getMetaTagHandler() item=__metaTag glue="\n"}{unsafe:$__metaTag}{/implode}
55
{event name='metaTags'}
66

77
<!-- Stylesheets -->
8-
{@$__wcf->getStyleHandler()->getStylesheet()}
8+
{unsafe:$__wcf->getStyleHandler()->getStylesheet()}
99
{event name='stylesheets'}
1010

1111
<meta name="timezone" content="{$__wcf->user->getTimeZone()->getName()}">
1212

1313
{include file='headIncludeJavaScript'}
1414
{include file='headIncludeIcons'}
1515

16-
{@HEAD_CODE}
16+
{unsafe:HEAD_CODE}

com.woltlab.wcf/templates/headIncludeJavaScript.tpl

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
*}
44

55
<script data-cfasync="false">
6-
var WCF_PATH = '{@$__wcf->getPath()}';
7-
var WSC_API_URL = '{@$__wcf->getPath()}';
6+
var WCF_PATH = '{unsafe:$__wcf->getPath()|encodeJS}';
7+
var WSC_API_URL = '{unsafe:$__wcf->getPath()|encodeJS}';
88
var WSC_RPC_API_URL = '{link controller="Api" id="rpc"}{/link}';
99
{* The SECURITY_TOKEN is defined in wcf.globalHelper.js *}
10-
var LANGUAGE_ID = {@$__wcf->getLanguage()->languageID};
10+
var LANGUAGE_ID = {$__wcf->getLanguage()->languageID};
1111
var LANGUAGE_USE_INFORMAL_VARIANT = {if LANGUAGE_USE_INFORMAL_VARIANT}true{else}false{/if};
12-
var TIME_NOW = {@TIME_NOW};
13-
var LAST_UPDATE_TIME = {@LAST_UPDATE_TIME};
12+
var TIME_NOW = {TIME_NOW};
13+
var LAST_UPDATE_TIME = {LAST_UPDATE_TIME};
1414
var ENABLE_DEBUG_MODE = {if ENABLE_DEBUG_MODE}true{else}false{/if};
1515
var ENABLE_PRODUCTION_DEBUG_MODE = {if ENABLE_PRODUCTION_DEBUG_MODE}true{else}false{/if};
1616
var ENABLE_DEVELOPER_TOOLS = {if ENABLE_DEVELOPER_TOOLS}true{else}false{/if};
17-
var PAGE_TITLE = '{PAGE_TITLE|phrase|encodeJS}';
17+
var PAGE_TITLE = '{unsafe:PAGE_TITLE|phrase|encodeJS}';
1818
19-
var REACTION_TYPES = {@$__wcf->getReactionHandler()->getReactionsJSVariable()};
19+
var REACTION_TYPES = {unsafe:$__wcf->getReactionHandler()->getReactionsJSVariable()};
2020
2121
{if ENABLE_DEBUG_MODE}
2222
{* This constant is a compiler option, it does not exist in production. *}
@@ -31,7 +31,7 @@
3131
{/if}
3232
</script>
3333

34-
<script data-cfasync="false" src="{$__wcf->getPath()}js/WoltLabSuite/WebComponent.min.js?v={@LAST_UPDATE_TIME}"></script>
34+
<script data-cfasync="false" src="{$__wcf->getPath()}js/WoltLabSuite/WebComponent.min.js?v={LAST_UPDATE_TIME}"></script>
3535
<script data-cfasync="false" src="{$phrasePreloader->getUrl($__wcf->language)}"></script>
3636

3737
{js application='wcf' file='require' bundle='WoltLabSuite.Core' core='true' hasTiny=true}
@@ -41,8 +41,8 @@
4141
{js application='wcf' file='3rdParty/tslib' bundle='WoltLabSuite.Core' core='true' hasTiny=true}
4242
<script data-cfasync="false">
4343
requirejs.config({
44-
baseUrl: '{@$__wcf->getPath()}js',
45-
urlArgs: 't={@LAST_UPDATE_TIME}'
44+
baseUrl: '{unsafe:$__wcf->getPath()|encodeJS}js',
45+
urlArgs: 't={LAST_UPDATE_TIME}'
4646
{hascontent}
4747
, paths: {
4848
{content}{event name='requirePaths'}{/content}
@@ -66,9 +66,9 @@ window.addEventListener('pageshow', function(event) {
6666
{/hascontent}
6767
6868
User.init(
69-
{@$__wcf->user->userID},
70-
{if $__wcf->user->userID}'{@$__wcf->user->username|encodeJS}'{else}''{/if},
71-
{if $__wcf->user->userID}'{@$__wcf->user->getLink()|encodeJS}'{else}''{/if},
69+
{$__wcf->user->userID},
70+
{if $__wcf->user->userID}'{unsafe:$__wcf->user->username|encodeJS}'{else}''{/if},
71+
{if $__wcf->user->userID}'{unsafe:$__wcf->user->getLink()|encodeJS}'{else}''{/if},
7272
'{link controller='GuestTokenDialog'}{/link}'
7373
);
7474
@@ -79,7 +79,7 @@ window.addEventListener('pageshow', function(event) {
7979
},
8080
{if $__wcf->user->userID && SERVICE_WORKER_PUBLIC_KEY !== ''}
8181
serviceWorker: {
82-
publicKey: '{@SERVICE_WORKER_PUBLIC_KEY|encodeJS}',
82+
publicKey: '{unsafe:SERVICE_WORKER_PUBLIC_KEY|encodeJS}',
8383
serviceWorkerJsUrl: '{$__wcf->getPath('wcf')}service-worker/',
8484
registerUrl: '{link controller="RegisterServiceWorker"}{/link}',
8585
notificationLastReadTime: {$__wcf->getUserNotificationHandler()->getTimeOfLastReadNotification()}
@@ -137,8 +137,8 @@ window.addEventListener('pageshow', function(event) {
137137

138138
<script data-relocate="true">
139139
WCF.User.init(
140-
{@$__wcf->user->userID},
141-
{if $__wcf->user->userID}'{@$__wcf->user->username|encodeJS}'{else}''{/if}
140+
{$__wcf->user->userID},
141+
{if $__wcf->user->userID}'{unsafe:$__wcf->user->username|encodeJS}'{else}''{/if}
142142
);
143143
</script>
144144

com.woltlab.wcf/templates/headIncludeJsonLd.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
{
55
"@context": "http://schema.org",
66
"@type": "WebSite",
7-
"url": {@$__websiteUrl|json},
7+
"url": {unsafe:$__websiteUrl|json},
88
"potentialAction": {
99
"@type": "SearchAction",
10-
"target": {@$__searchTargetUrl|json},
10+
"target": {unsafe:$__searchTargetUrl|json},
1111
"query-input": "required name=search_term_string"
1212
}
1313
}

0 commit comments

Comments
 (0)