Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/5.3' into feature/twig-content…
Browse files Browse the repository at this point in the history
…-url

# Conflicts:
#	core-bundle/contao/templates/twig/content_element/_base.html.twig
  • Loading branch information
aschempp committed Jan 26, 2024
2 parents 52d59cf + 6530788 commit b35e4d3
Show file tree
Hide file tree
Showing 55 changed files with 185 additions and 82 deletions.
4 changes: 2 additions & 2 deletions core-bundle/assets/controllers/toggle-nodes-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ export default class extends Controller {
window.dispatchEvent(new CustomEvent('structure'));
this.expandToggler(el);

// HOOK
window.dispatchEvent(new CustomEvent('ajax_change'));
// HOOK (see #6752)
window.fireEvent('ajax_change')
}

this.loadToggler(el, false);
Expand Down
5 changes: 5 additions & 0 deletions core-bundle/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,11 @@ services:
arguments:
- '@contao.routing.response_context_accessor'

contao.twig.string_runtime:
class: Contao\CoreBundle\Twig\Runtime\StringRuntime
arguments:
- '@contao.framework'

contao.twig.url_runtime:
class: Contao\CoreBundle\Twig\Runtime\UrlRuntime
arguments:
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/contao/classes/Crawl.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function run()
->withMaxDurationInSeconds(20)
->withLogger($this->createLogger($factory, $activeSubscribers, $jobId, $debugLogPath));

$template->hint = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['crawlHint'], $concurrency, 'contao.backend.crawl_concurrency');
$template->hint = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['crawlHint'], $concurrency, 'contao.backend.crawl_concurrency', 'https://to.contao.org/docs/crawler');

if (Environment::get('isAjaxRequest'))
{
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/contao/config/mimetypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
// Videos
'mp4' => array('video/mp4', 'iconMP4.svg'),
'm4v' => array('video/x-m4v', 'iconM4V.svg'),
'mov' => array('video/mov', 'iconMOV.svg'),
'mov' => array('video/quicktime', 'iconMOV.svg'),
'wmv' => array('video/wmv', 'iconWMV.svg'),
'webm' => array('video/webm', 'iconWEBM.svg'),
'qt' => array('video/quicktime', 'iconQT.svg'),
Expand Down
5 changes: 5 additions & 0 deletions core-bundle/contao/controllers/BackendConfirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public function run()
{
$objSession = System::getContainer()->get('request_stack')->getSession();

if (!$objSession->has('INVALID_TOKEN_URL'))
{
$this->redirect(System::getContainer()->get('router')->generate('contao_backend'));
}

// Redirect to the back end home page
if (Input::post('FORM_SUBMIT') == 'invalid_token_url')
{
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/contao/forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ protected function processFormData($arrSubmitted, $arrLabels, $arrFields, $arrFi
if ($this->objModel->confirmation)
{
$message = $this->objModel->confirmation;
$message = System::getContainer()->get('contao.string.simple_token_parser')->parse($message, array_map(StringUtil::specialchars(...), $arrSubmitted));
$message = System::getContainer()->get('contao.string.simple_token_parser')->parse($message, ArrayUtil::mapRecursive(StringUtil::specialchars(...), $arrSubmitted));
$message = System::getContainer()->get('contao.insert_tag.parser')->replaceInline($message);

$requestStack = System::getContainer()->get('request_stack');
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/contao/languages/en/tl_maintenance.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<source>Automatically log in a front end member to index protected pages.</source>
</trans-unit>
<trans-unit id="tl_maintenance.crawlHint">
<source>Your website is currently crawled with %d concurrent requests. If your server can handle more than %1$d concurrent requests, ask your system administrator to increase the &lt;code&gt;%s&lt;/code&gt; setting in the system configuration to speed up the crawling process.</source>
<source>Your website is currently crawled with %d concurrent requests. If your server can handle more than %1$d concurrent requests, ask your system administrator to increase the &lt;code&gt;%s&lt;/code&gt; setting in the system configuration to speed up the crawling process. Refer to the &lt;a href=&quot;%s&quot; target=&quot;_blank&quot; rel=&quot;noreferrer noopener&quot;&gt;Contao manual&lt;/a&gt; for more information.</source>
</trans-unit>
<trans-unit id="tl_maintenance.crawlWaitToBeFinished">
<source>The crawler is currently working. Please wait for it to finish to see the results.</source>
Expand Down
5 changes: 5 additions & 0 deletions core-bundle/contao/library/Contao/ArrayUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,9 @@ public static function flattenToString(array $arrArray): string

return implode(', ', $result);
}

public static function mapRecursive(callable $fn, array $arr): array
{
return array_map(static fn ($item) => \is_array($item) ? self::mapRecursive($fn, $item) : $fn($item), $arr);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<!-- indexer::stop -->
{%- endif %}

{% block wrapper %}
{# Wrapper attributes: add the user defined ID/classes and also add the
template name (e.g. "content_element/text") as a class #}
{% set attributes = attrs(attributes|default)
.setIfExists('id', element_html_id|default)
.addClass([element_css_classes, "content-#{type|replace({'_': '-'})}"])
%}
{# Wrapper attributes: add the user defined ID/classes and also add the
template name (e.g. "content_element/text") as a class #}
{% set attributes = attrs(attributes|default)
.setIfExists('id', element_html_id|default)
.addClass([element_css_classes, "content-#{type|replace({'_': '-'})}"])
%}

{% block wrapper %}
{# Wrapper element around headline and content #}
<{% block wrapper_tag %}div{% endblock %}{% block attributes %}{{ attributes }}{% endblock %}>
{%- block inner %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{% extends "@Contao/content_element/_base.html.twig" %}
{% use "@Contao/component/_headline.html.twig" %}

{% block wrapper_tag %}{{ headline.tag_name|default('h1') }}{% endblock %}

{% block inner %}
{{- block('headline_inner') -}}
{% block wrapper %}
{# The "headline" content element does not have a wrapper element, so the
wrapper attributes must be applied to the "_headline" component. #}
{% with {headline: headline|default(_context)|merge({attributes})} %}
{{ block('headline_component') }}
{% endwith %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{# Link wrapping text #}
{% block text_link %}
{{- text_before -}}
<a{{ attrs(link_attributes|default) }}>{{ link_text }}</a>
<a{{ attrs(link_attributes|default) }}>{{ link_text|insert_tag }}</a>
{{- text_after -}}
{% endblock %}
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{% block text %}
{% set text_attributes = attrs(text_attributes|default).addClass('rte') %}
<div{% block text_attributes %}{{ text_attributes }}{% endblock %}>
{{ text|csp_inline_styles|insert_tag|raw }}
{{ text|csp_inline_styles|insert_tag|encode_email|raw }}
</div>
{% endblock %}
{% endblock %}
2 changes: 2 additions & 0 deletions core-bundle/contao/themes/flexible/backend.c2a75b4f.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions core-bundle/contao/themes/flexible/backend.e52db756.css

This file was deleted.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions core-bundle/contao/themes/flexible/conflict.41a64ff6.css

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions core-bundle/contao/themes/flexible/conflict.aa6b9c95.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion core-bundle/contao/themes/flexible/diff.028ed04c.css.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core-bundle/contao/themes/flexible/diff.171af75f.css.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions core-bundle/contao/themes/flexible/entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
"entrypoints": {
"backend": {
"css": [
"/system/themes/flexible/backend.e52db756.css"
"/system/themes/flexible/backend.c2a75b4f.css"
]
},
"confirm": {
"css": [
"/system/themes/flexible/confirm.5231eaa5.css"
"/system/themes/flexible/confirm.c2996dd4.css"
]
},
"conflict": {
"css": [
"/system/themes/flexible/conflict.41a64ff6.css"
"/system/themes/flexible/conflict.aa6b9c95.css"
]
},
"diff": {
"css": [
"/system/themes/flexible/diff.028ed04c.css"
"/system/themes/flexible/diff.171af75f.css"
]
},
"help": {
"css": [
"/system/themes/flexible/help.5cbdb4ee.css"
"/system/themes/flexible/help.2ee3bcf2.css"
]
},
"login": {
"css": [
"/system/themes/flexible/login.dcee719f.css"
"/system/themes/flexible/login.fb2833be.css"
]
},
"popup": {
"css": [
"/system/themes/flexible/popup.751f0537.css"
"/system/themes/flexible/popup.4728c2fc.css"
]
},
"tinymce": {
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core-bundle/contao/themes/flexible/help.2ee3bcf2.css.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion core-bundle/contao/themes/flexible/help.5cbdb4ee.css.map

This file was deleted.

2 changes: 0 additions & 2 deletions core-bundle/contao/themes/flexible/login.dcee719f.css

This file was deleted.

1 change: 0 additions & 1 deletion core-bundle/contao/themes/flexible/login.dcee719f.css.map

This file was deleted.

2 changes: 2 additions & 0 deletions core-bundle/contao/themes/flexible/login.fb2833be.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core-bundle/contao/themes/flexible/login.fb2833be.css.map

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions core-bundle/contao/themes/flexible/manifest.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"backend.css": "/system/themes/flexible/backend.e52db756.css",
"confirm.css": "/system/themes/flexible/confirm.5231eaa5.css",
"conflict.css": "/system/themes/flexible/conflict.41a64ff6.css",
"diff.css": "/system/themes/flexible/diff.028ed04c.css",
"help.css": "/system/themes/flexible/help.5cbdb4ee.css",
"login.css": "/system/themes/flexible/login.dcee719f.css",
"popup.css": "/system/themes/flexible/popup.751f0537.css",
"backend.css": "/system/themes/flexible/backend.c2a75b4f.css",
"confirm.css": "/system/themes/flexible/confirm.c2996dd4.css",
"conflict.css": "/system/themes/flexible/conflict.aa6b9c95.css",
"diff.css": "/system/themes/flexible/diff.171af75f.css",
"help.css": "/system/themes/flexible/help.2ee3bcf2.css",
"login.css": "/system/themes/flexible/login.fb2833be.css",
"popup.css": "/system/themes/flexible/popup.4728c2fc.css",
"tinymce.css": "/system/themes/flexible/tinymce.e5009f94.css",
"tinymce-dark.css": "/system/themes/flexible/tinymce-dark.596023db.css",
"backend.e52db756.css.map": "/system/themes/flexible/backend.e52db756.css.map",
"confirm.5231eaa5.css.map": "/system/themes/flexible/confirm.5231eaa5.css.map",
"conflict.41a64ff6.css.map": "/system/themes/flexible/conflict.41a64ff6.css.map",
"diff.028ed04c.css.map": "/system/themes/flexible/diff.028ed04c.css.map",
"help.5cbdb4ee.css.map": "/system/themes/flexible/help.5cbdb4ee.css.map",
"login.dcee719f.css.map": "/system/themes/flexible/login.dcee719f.css.map",
"popup.751f0537.css.map": "/system/themes/flexible/popup.751f0537.css.map",
"backend.c2a75b4f.css.map": "/system/themes/flexible/backend.c2a75b4f.css.map",
"confirm.c2996dd4.css.map": "/system/themes/flexible/confirm.c2996dd4.css.map",
"conflict.aa6b9c95.css.map": "/system/themes/flexible/conflict.aa6b9c95.css.map",
"diff.171af75f.css.map": "/system/themes/flexible/diff.171af75f.css.map",
"help.2ee3bcf2.css.map": "/system/themes/flexible/help.2ee3bcf2.css.map",
"login.fb2833be.css.map": "/system/themes/flexible/login.fb2833be.css.map",
"popup.4728c2fc.css.map": "/system/themes/flexible/popup.4728c2fc.css.map",
"tinymce.e5009f94.css.map": "/system/themes/flexible/tinymce.e5009f94.css.map",
"tinymce-dark.596023db.css.map": "/system/themes/flexible/tinymce-dark.596023db.css.map"
}

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core-bundle/contao/themes/flexible/popup.4728c2fc.css.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion core-bundle/contao/themes/flexible/popup.751f0537.css.map

This file was deleted.

4 changes: 0 additions & 4 deletions core-bundle/contao/themes/flexible/styles/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,6 @@ a.tl_submit {
height: auto;
}

.dcapicker .tl_text {
padding-right: 26px;
}

/* Tips */
.tl_tip {
height: 15px;
Expand Down
10 changes: 7 additions & 3 deletions core-bundle/contao/themes/flexible/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ body.popup {
background: var(--content-bg);
border: 1px solid var(--content-border);
box-shadow: 0 1px 6px rgba(0,0,0,.2);
z-index: 2;
z-index: 4; /* Above .jump-targets */
color: var(--text);
text-align: left;
opacity: 0;
Expand Down Expand Up @@ -742,7 +742,7 @@ h2.sub_headline {
border-bottom: 1px solid var(--content-border);
position: sticky;
top: 0;
z-index: 3;
z-index: 3; /* Above TinyMCE */
}

.jump-targets .inner {
Expand Down Expand Up @@ -850,7 +850,7 @@ h2.sub_headline {
border-top: 1px solid var(--content-border);
position: sticky;
bottom: 0;
z-index: 2;
z-index: 3; /* Above TinyMCE */
}

.tl_submit_container {
Expand Down Expand Up @@ -969,6 +969,10 @@ h2.sub_headline {
line-height: 1.3;
}

#tl_crawl .crawl-hint a {
text-decoration: underline;
}

#tl_crawl .subscriber-log {
display: none;
padding: 5px 0;
Expand Down
1 change: 0 additions & 1 deletion core-bundle/public/backend.42df1514.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core-bundle/public/backend.ef695b97.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core-bundle/public/entrypoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"entrypoints": {
"backend": {
"js": [
"/bundles/contaocore/backend.42df1514.js"
"/bundles/contaocore/backend.ef695b97.js"
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions core-bundle/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"backend.js": "/bundles/contaocore/backend.42df1514.js",
"backend.42df1514.js.map": "/bundles/contaocore/backend.42df1514.js.map"
"backend.js": "/bundles/contaocore/backend.ef695b97.js",
"backend.ef695b97.js.map": "/bundles/contaocore/backend.ef695b97.js.map"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;

/**
* @internal
*/
class StripCookiesSubscriber implements EventSubscriberInterface
{
private const DENY_LIST = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;

/**
* @internal
*/
class StripQueryParametersSubscriber implements EventSubscriberInterface
{
private const DENY_LIST = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public function supports(Request $request): bool|null
{
return $request->isMethod('POST')
&& $request->request->has('FORM_SUBMIT')
&& preg_match('/^tl_login(_\d+)?$/', (string) $request->request->get('FORM_SUBMIT'));
&& \is_string($request->request->get('FORM_SUBMIT'))
&& preg_match('/^tl_login(_\d+)?$/', $request->request->get('FORM_SUBMIT'));
}

public function authenticate(Request $request): Passport
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/src/String/SimpleTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function replaceTokens(string $subject, array $data): string
{
// Replace tokens
return preg_replace_callback(
'/##([^=!<>\s]+?)##/',
'/##([^#=!<>\s][^=!<>\s]*?)##/',
function (array $matches) use ($data) {
if (!\array_key_exists($matches[1], $data)) {
$this->logger?->log(LogLevel::INFO, sprintf('Tried to parse unknown simple token "%s".', $matches[1]));
Expand Down
6 changes: 6 additions & 0 deletions core-bundle/src/Twig/Extension/ContaoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Contao\CoreBundle\Twig\Runtime\PictureConfigurationRuntime;
use Contao\CoreBundle\Twig\Runtime\SanitizerRuntime;
use Contao\CoreBundle\Twig\Runtime\SchemaOrgRuntime;
use Contao\CoreBundle\Twig\Runtime\StringRuntime;
use Contao\CoreBundle\Twig\Runtime\UrlRuntime;
use Contao\FrontendTemplateTrait;
use Contao\Template;
Expand Down Expand Up @@ -304,6 +305,11 @@ public function getFilters(): array
[CspRuntime::class, 'inlineStyles'],
['preserves_safety' => ['html']],
),
new TwigFilter(
'encode_email',
[StringRuntime::class, 'encodeEmail'],
['preserves_safety' => ['contao_html', 'html']],
),
];
}

Expand Down
34 changes: 34 additions & 0 deletions core-bundle/src/Twig/Runtime/StringRuntime.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

/*
* This file is part of Contao.
*
* (c) Leo Feyer
*
* @license LGPL-3.0-or-later
*/

namespace Contao\CoreBundle\Twig\Runtime;

use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\StringUtil;
use Twig\Extension\RuntimeExtensionInterface;

final class StringRuntime implements RuntimeExtensionInterface
{
/**
* @internal
*/
public function __construct(private readonly ContaoFramework $framework)
{
}

public function encodeEmail(string $html): string
{
$this->framework->initialize();

return $this->framework->getAdapter(StringUtil::class)->encodeEmail($html);
}
}

0 comments on commit b35e4d3

Please sign in to comment.