Commit e5bf0c14 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[TASK] https as default scheme in f:uri.external and f:link.external

When no scheme is given using f:uri.external or
f:link.external fluid view helpers, they now fall
back to https instead of http.

Resolves: #94615
Releases: master
Change-Id: I33ce251d4f38cd504d163dd91f70fbe753952f2d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70026

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Jochen's avatarJochen <rothjochen@gmail.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Jochen's avatarJochen <rothjochen@gmail.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 8972957a
.. include:: ../../Includes.txt
==============================================================================================
Important: #94615 - Fluid view helpers f:link.external and f:uri.external use https by default
==============================================================================================
See :issue:`94615`
Description
===========
When using the fluid view helpers :html:`f:uri.external` or :html:`f:link.external` without
an explicitly specified scheme, the target link now uses :html:`https` instead of :html:`http`.
Given the following fluid snippets:
.. code-block:: html
<f:link.external uri="www.some-domain.tld">some content</f:link.external>
<f:uri.external uri="www.some-domain.tld" />
The result before:
.. code-block:: html
<a href="http://www.some-domain.tld">some content</a>
http://www.some-domain.tld
New result:
.. code-block:: html
<a href="https://www.some-domain.tld">some content</a>
https://www.some-domain.tld
If the new default can not be used, the :html:`http` scheme needs to be specified. Examples:
.. code-block:: html
<f:link.external uri="http://www.some-domain.tld">some content</f:link.external>
<f:link.external uri="www.some-domain.tld" defaultScheme="http">some content</f:link.external>
<f:uri.external uri="http://www.some-domain.tld" />
<f:uri.external uri="www.some-domain.tld" defaultScheme="http" />
.. index:: Fluid, ext:fluid
......@@ -28,11 +28,11 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
*
* ::
*
* <f:link.external uri="http://www.typo3.org" target="_blank">external link</f:link.external>
* <f:link.external uri="https://www.typo3.org" target="_blank">external link</f:link.external>
*
* Output::
*
* <a href="http://www.typo3.org" target="_blank">external link</a>
* <a href="https://www.typo3.org" target="_blank">external link</a>
*
* Custom default scheme
* ---------------------
......@@ -59,7 +59,7 @@ class ExternalViewHelper extends AbstractTagBasedViewHelper
{
parent::initializeArguments();
$this->registerArgument('uri', 'string', 'The URI that will be put in the href attribute of the rendered link tag', true);
$this->registerArgument('defaultScheme', 'string', 'Scheme the href attribute will be prefixed with if specified $uri does not contain a scheme already', false, 'http');
$this->registerArgument('defaultScheme', 'string', 'Scheme the href attribute will be prefixed with if specified $uri does not contain a scheme already', false, 'https');
$this->registerUniversalTagAttributes();
$this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
$this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
......
......@@ -31,9 +31,9 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
*
* ::
*
* <f:uri.external uri="http://www.typo3.org" />
* <f:uri.external uri="https://www.typo3.org" />
*
* ``http://www.typo3.org``
* ``https://www.typo3.org``
*
* Custom default scheme
* ---------------------
......@@ -56,7 +56,7 @@ class ExternalViewHelper extends AbstractViewHelper
public function initializeArguments()
{
$this->registerArgument('uri', 'string', 'target URI', true);
$this->registerArgument('defaultScheme', 'string', 'scheme the href attribute will be prefixed with if specified $uri does not contain a scheme already', false, 'http');
$this->registerArgument('defaultScheme', 'string', 'scheme the href attribute will be prefixed with if specified $uri does not contain a scheme already', false, 'https');
}
/**
......
......@@ -25,9 +25,9 @@ class ExternalViewHelperTest extends FunctionalTestCase
public function renderDataProvider(): array
{
return [
'renderAddsHttpPrefixIfSpecifiedUriDoesNotContainScheme' => [
'renderAddsHttpsPrefixIfSpecifiedUriDoesNotContainScheme' => [
'<f:link.external uri="www.some-domain.tld">some content</f:link.external>',
'<a href="http://www.some-domain.tld">some content</a>',
'<a href="https://www.some-domain.tld">some content</a>',
],
'renderAddsSpecifiedSchemeIfUriDoesNotContainScheme' => [
'<f:link.external uri="www.some-domain.tld" defaultScheme="ftp">some content</f:link.external>',
......
......@@ -31,7 +31,7 @@ class ExternalViewHelperTest extends FunctionalTestCase
],
'renderAddsSchemeIfUriDoesNotContainScheme' => [
'<f:uri.external uri="www.some-domain.tld" />',
'http://www.some-domain.tld',
'https://www.some-domain.tld',
],
'renderAddsSpecifiedSchemeIfUriDoesNotContainScheme' => [
'<f:uri.external uri="some-domain.tld" defaultScheme="ftp" />',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment