Bug #87919
closed
config.absRefPrefix not working for links in HMENU, fluid generated links like <f:link.page ... or <f:link.typolink ...
Added by Martin Weymayer over 5 years ago.
Updated almost 2 years ago.
Description
Steps to reproduce:
1) install typo3
2) add menu in typoscript like:
lib.menu >
lib.menu = HMENU
lib.menu {
special = directory
special.value = 1
1 = TMENU
1 {
expAll =1
wrap = <ul>|</ul>
noBlur = 1
NO = 1
NO {
wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
stdWrap.htmlSpecialChars = 1
}
ACT <.NO
ACT {
wrapItemAndSub = <li class="first active">|</li> |*| <li class="active">|</li> |*| <li class="last active">|</li>
stdWrap.htmlSpecialChars = 1
ATagParams = class="active"
} ....
3) add configuration config.absRefPrefix =
https://www.domain.at/
expected result:
Links in menu and fluid generated links should look like <a href="https://www.domain.at/page">....
actual result:
links look like <a href="/page">....
css files and images are including absolute path domain, but not links from menu and fluid generated
martin
Related issues
1 (1 open — 0 closed)
- Category set to TypoScript
I can confirm this in current 9.5.7. Also ckeditor and contentelement links are not prefixed.
I confirm for 9.5.11 and latest master,
It seems that config.absRefPrefix
is not considered on
1) TypoScript links built with typolink
function
2) HMENU
TypoScript objects
3) Links in CKEditor
4) Header of content elements (linked)
It is considered on
1) IMAGE
TypoScript objects
2) includeJS
and includeCSS
objects
- Related to Bug #82574: Inconsistent support of config.absRefPrefix in fluid/extbase added
Can confirm in typo3 v9.5.16 too.
Any news about this?
Can confirm this for 10.4.12.
Any news?
You can use `(NO/ACT/...).stdWrap.typolink.forceAbsoluteUrl`.
I think `config.absRefPrefix` should be deprecated since it doesn't make any sense any more with site config. `typolink.forceAbsoluteUrl` is able to replace it where needed.
Jonas Eberle wrote in #note-8:
You can use `(NO/ACT/...).stdWrap.typolink.forceAbsoluteUrl`.
I think `config.absRefPrefix` should be deprecated since it doesn't make any sense any more with site config. `typolink.forceAbsoluteUrl` is able to replace it where needed.
How to enable the absolute url for ckeditor links like <a href="t3://page?uid=123">Link</a>
?
We use page links in the powermail body ckeditor fields. Without the absolute path, the link is not working in a email.
config.absRefPrefix is still not working in TYPO3 10.4.13.
Just found this comment from benni mack: https://forge.typo3.org/issues/93039#note-1
For ckeditor typolinks this config make every link absolute:
lib.parseFunc_RTE.tags.a.typolink {
forceAbsoluteUrl = 1
forceAbsoluteUrl.scheme = https
}
In fluid links there is the absolute
attribute.
We have also this issue. We export the HTML for Newsletter Mails. So it's necessary that all links of the page are absolute.
Current Middleware Workaround in TYPO3 v10:
<?php
namespace Clickstorm\CsNewsletterExport\Middleware;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Http\NullResponse;
use TYPO3\CMS\Core\Http\RequestFactory;
use TYPO3\CMS\Core\Http\ResponseFactory;
use TYPO3\CMS\Core\Http\Stream;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
/**
* prefix all links and src with $GLOBALS['TSFE']->absRefPrefix
*
* Class GenerateAbsoluteLinksMiddleware
* @package Clickstorm\CsNewsletterExport\Middleware
*/
class GenerateAbsoluteLinksMiddleware implements MiddlewareInterface
{
/** @var ResponseFactory */
private $responseFactory;
/** @var RequestFactory */
private $requestFactory;
/** @var ClientInterface */
private $client;
public function __construct(
ResponseFactoryInterface $responseFactory,
RequestFactoryInterface $requestFactory,
ClientInterface $client
) {
$this->responseFactory = $responseFactory;
$this->requestFactory = $requestFactory;
$this->client = $client;
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
if (
!($response instanceof NullResponse)
&& $GLOBALS['TSFE'] instanceof TypoScriptFrontendController
&& $GLOBALS['TSFE']->absRefPrefix
&& $GLOBALS['TSFE']-> !== '/'
&& $GLOBALS['TSFE']-> !== 'auto'
) {
$body = $response->getBody();
$body->rewind();
$contents = $response->getBody()->getContents();
$content = $this->parseRelativeToAbsoluteUrls($contents);
$body = new Stream('php://temp', 'rw');
$body->write($content);
$response = $response->withBody($body);
}
return $response;
}
protected function parseRelativeToAbsoluteUrls(string $input = ''): string
{
// https://thydzik.com/convert-relative-links-to-absolute-links-with-php-regex/
$prefix = $GLOBALS['TSFE']->absRefPrefix;
return preg_replace('/((?:href|src) *= *[\'"])(\/)/i', "$1$prefix", $input);
}
}
I agree since site configuration exists, „absRefPrefix“ is not necessary any longer. But when it gets deprecated or removed, a new configuration option should be introduced to globally enable creation of absolute links, based on site configuration!
- Status changed from New to Under Review
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
- Status changed from Resolved to Closed
Also available in: Atom
PDF