Coder Social home page Coder Social logo

friendsoftypo3 / jumpurl Goto Github PK

View Code? Open in Web Editor NEW
6.0 9.0 16.0 162 KB

Extension to enable redirects based on short links ("jump urls") to specific pages while keeping click statistics

License: GNU General Public License v2.0

PHP 98.51% Makefile 1.49%

jumpurl's Introduction

jumpurl's People

Contributors

alagts avatar alexander-nitsche avatar astehlik avatar bmack avatar devmes avatar dmitryd avatar helhum avatar ichhabrecht avatar joey-bolts avatar masi avatar mediaessenz avatar ohader avatar patta avatar ssfgizmo avatar stephfh avatar wolffc avatar wouter90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jumpurl's Issues

TYPO3 10 compatibiliy

Hey,

im currently working on getting direct_mail compatible with TYPO3 10 which depends on this package. Would love to see this getting ready for the upcoming 10 LTS version 🙂

Error in Typo3 v. 10.4.xx after click on module redirects

Following error occures:

Return value of FoT3\Jumpurl\JumpUrlProcessor::getTypoScriptFrontendController() must be an instance of TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController, null returned

Solution:

After changing lines in file jumpurl\Classes\JumpUrlProcessor.php after line 208:

 protected function getTypoScriptFrontendController(): TypoScriptFrontendController
{
    return $this->frontendController ?? $GLOBALS['TSFE'];
} 

in

protected function getTypoScriptFrontendController()
{
return $this->frontendController ?? $GLOBALS['TSFE'];
}
everything works fine again.

Error with latest version in 9.5

After updating to version 8.0 I get error on root page in page view backend:

Return value of FoT3\Jumpurl\JumpUrlProcessor::getTypoScriptFrontendController() must be an instance of TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController, null returned

downgrading to 7.8 solves this problem.

Error with Typo3 11 and PHP 8

Hi,

Jumpurl generates a warning in Typo3 11.5.15 and PHP 8. It's "typo3.sol.lu.se/typo3conf/ext/jumpurl/Classes/Middleware/JumpUrlHandler.php", line 60:
$jumpUrl = (string)$request->getQueryParams()['jumpurl'] ?? '';"
that generates a missing array key warning. Removing the (string) fixes the problem.

Kind regards

Tomas

7.6 jumpurl.secure and fluid_styled_content

Hi
i'm trying to use the jumpurl.secure over a secured folder on nginx but it doesn't work.
i'm using fluid_styled_content.

the jumpurl redirect works, just the secure doesn't.

a quick debug show the secure parameter is not passed in the $configuration array.

maybe it's just i miss some TS.

config.jumpurl_enable = 1
config.jumpurl.secure = 1

Thanks

Service tag "event.listener" - error

I'm getting the following error when installing this extensions:

Service tag "event.listener" requires an event attribute to be defined, missing in: FoT3\Jumpurl\TypoLink\LinkModifier

extending Services.yaml with the line

event: FoT3\Jumpurl\TypoLink\LinkModifier

inside of event.listener solves the problem

Not compatiblewith TYPO3 v9 LTS

Hello,we have found that jumpurl is notcompatible with TYPO3 9 : there are three calls to removed methods.
I would like to knowif there is any plan to fix this and if there is a timing.
In any case I and my colleagues could be in a position to contribute to this and I wonder if could be sensible to open a new branch for this.
Best regards

PSR-7 request is missing in ContentObjectRenderer

hey, I'm using the Solr and Jumpurl plugins. for indexing queues, solr uses a CLI command and I use this CLI command too. but unfortunately, I received this error "PSR-7 request is missing in ContentObjectRenderer. Inject with start(), setRequest() or provide via $GLOBALS['TYPO3_REQUEST']."
this error is a core error in typo3\sysext\frontend\Classes\ContentObject\ContentObjectRenderer.php file.it is beacuse that $GLOBALS['TYPO3_REQUEST'] and ServerRequestInterface are not set. actually in CLI command both of $GLOBALS['TYPO3_REQUEST'] and request will not set . I thought it was a bug from Solr but I saw this discussion at TYPO3-Solr/ext-solr#2973 and they have the following claim:
"When initializing the TSFE a TYPO3_REQUEST is also initialized. A request must always have an applicationtype attribute. If no applicationType is given ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST']) can't be used and throws an exception."

and they ask us If we have troubles with third-party code, we should give the hint to the maintainer of those extensions:

I added a little code in ext/jumpurl/Classes/TypoLink/LinkModifier.php(the error was here created) and checked if $GLOBALS['TYPO3_REQUEST'] set or not and after that, I could run the CLI command in solr without any errors. My solution was just a quick fix and surely you will have a more complete solution. I would be very grateful if you write a solution for this issue in new updates, I need your plugin :)

the following codes are :
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Http\ServerRequest;

public function __invoke(AfterLinkIsGeneratedEvent $event): void
{

if (($GLOBALS['TYPO3_REQUEST'] ?? null)instanceof ServerRequest && ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend())
{
(this if I used before I used your code)
if ($this->isEnabled($event)) {
$url = $event->getLinkResult()->getUrl();
$context = $event->getLinkResult()->getType();
$configuration = $event->getLinkResult()->getLinkConfiguration();
$this->contentObjectRenderer = $event->getContentObjectRenderer();
$this->frontendController = $this->contentObjectRenderer->getTypoScriptFrontendController();

// Strip the absRefPrefix from the URLs.
$urlPrefix = (string)$this->getTypoScriptFrontendController()->absRefPrefix;
if ($urlPrefix !== '' && str_starts_with($url, $urlPrefix)) {
    $url = substr($url, strlen($urlPrefix));
}

// Make sure the slashes in the file URL are not encoded.
if ($context === LinkService::TYPE_FILE) {
    $url = str_replace('%2F', '/', rawurlencode(rawurldecode($url)));
}

if ($context === LinkService::TYPE_PAGE && $url === '') {
    $url = '/';
}

$urlParameters = ['jumpurl' => $url];

$jumpUrlConfig = $configuration['jumpurl.'] ?? [];

// see if a secure File URL should be built
if (!empty($jumpUrlConfig['secure'])) {
    $secureParameters = $this->getParametersForSecureFile(
        $url,
        $jumpUrlConfig['secure.'] ?? []
    );
    $urlParameters = array_merge($urlParameters, $secureParameters);
} else {
    $urlParameters['juHash'] = JumpUrlUtility::calculateHash($url);
}

$typoLinkConfiguration = [
    'parameter' => $this->getTypoLinkParameter($jumpUrlConfig),
    'additionalParams' => GeneralUtility::implodeArrayForUrl('', $urlParameters),
];

$jumpurl = $this->getContentObjectRenderer()->typoLink_URL($typoLinkConfiguration);

// Now add the prefix again if it was not added by a typolink call already.
if ($urlPrefix !== '') {
    if (!str_starts_with($jumpurl, $urlPrefix)) {
        $jumpurl = $urlPrefix . $jumpurl;
    }
    if (!str_starts_with($url, $urlPrefix)) {
        $url = $urlPrefix . $url;
    }
}
$event->setLinkResult($event->getLinkResult()->withAttributes(['href' => $jumpurl, 'jumpurl' => $url]));

}
}

typo3 v12 - PSR-7 request is missing in ContentObjectRenderer

Hi,

On a composer typo3 v12 installation, i have this error when i index with typo3 solr :

1607172972: TYPO3\CMS\Frontend\ContentObject\Exception\ContentRenderingException: PSR-7 request is missing in ContentObjectRenderer. Inject with start(), setRequest() or provide via $GLOBALS['TYPO3_REQUEST']. 
in vendor/typo3/cms-frontend/Classes/ContentObject/ContentObjectRenderer.php:5900

Stack trace:
#0 vendor/typo3/cms-frontend/Classes/Typolink/AbstractTypolinkBuilder.php(212): TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->getRequest()
#1 vendor/friendsoftypo3/jumpurl/Classes/TypoLink/LinkModifier.php(200): TYPO3\CMS\Frontend\Typolink\AbstractTypolinkBuilder->getTypoScriptFrontendController()
#2 vendor/friendsoftypo3/jumpurl/Classes/TypoLink/LinkModifier.php(118): FoT3\Jumpurl\TypoLink\LinkModifier->getTypoScriptFrontendController()

Not sure if it is totally linked to "jumpurl" or "solr".

PHP 8 / Exception when clicking on jumpurls in newsletter-mail

Hello,
we are using direct_mail for sending newsletters and jumpurl in footer links for unsubscribe, web-version etc.
When clicking on such a jumpurl in the newsletter we get an exception on the site saying:
str_replace(): Argument #2 ($replace) must be of type array|string, int given

We are using the following
Typo3 11.5.25
direct_mail 9.0.2
jumpurl 8.1.0
PHP 8.1.18

When switching back to PHP 7.4 the error doesn´t occur.

Can you please check the extension regarding PHP 8.1?

Thanks in advance
Stefanie

Undefined global variable $TSFE in redirect module

TYPO3 11.5.26
PHP 8.1.18
jumpurl 8.1.0

Backend redirect module:

(1/1) #1476107295 TYPO3\CMS\Core\Error\Exception

PHP Warning: Undefined global variable $TSFE in /var/www/html/private/typo3conf/ext/jumpurl/Classes/JumpUrlProcessor.php line 41
in /var/www/html/private/typo3/sysext/core/Classes/Error/ErrorHandler.php line 137

        }

        $message = self::ERROR_LEVEL_LABELS[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine;
        if ($errorLevel & $this->exceptionalErrors) {
            throw new Exception($message, 1476107295);
        }

        $message = $this->getFormattedLogMessage($message);

at TYPO3\CMS\Core\Error\ErrorHandler->handleError(2, 'Undefined global variable $TSFE', '/var/www/html/private/typo3conf/ext/jumpurl/Classes/JumpUrlProcessor.php', 41)
in /var/www/html/private/typo3conf/ext/jumpurl/Classes/JumpUrlProcessor.php line 41

    protected $frontendController;

    public function __construct(TypoScriptFrontendController $typoScriptFrontendController = null, ContentObjectRenderer $contentObjectRenderer = null)
    {
        $this->frontendController = $typoScriptFrontendController ?? $GLOBALS['TSFE'];
        $this->contentObjectRenderer = $contentObjectRenderer;
    }

    /**

at FoT3\Jumpurl\JumpUrlProcessor->__construct()
in /var/www/html/private/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 3217

            return self::$container->get($className);
        }

        // Create new instance and call constructor with parameters
        $instance = new $finalClassName(...$constructorArguments);
        // Register new singleton instance, but only if it is not a known PSR-11 container service
        if ($instance instanceof SingletonInterface && !(self::$container !== null && self::$container->has($className))) {
            self::$singletonInstances[$finalClassName] = $instance;
        }
...

[BUG] Removed [SYS][doNotCheckReferer] configuration from core throws exception error

Since TYPO3 7.6.25 and 8.7.11 the [SYS][doNotCheckReferer] configuration is removed.
See: https://docs.typo3.org/typo3cms/extensions/core/latest/Changelog/8.7.x/Important-83768-RemoveReferrerCheck.html

In current jumpurl version 7.1.1 the configuration is used for referrer check.
See: https://docs.typo3.org/typo3cms/extensions/jumpurl/Configuration/Index.html#typo3-conf-vars

Now the be log throws exception errors:
Core: Exception handler (WEB): Uncaught TYPO3 Exception: The jumpUrl request was triggered by an illegal referrer. | RuntimeException thrown in file /.../typo3conf/ext/jumpurl/Classes/JumpUrlHandler.php in line 66. Requested URL: ...

Redirects tool in Typo3 11 with PHP 8 generates Undefined array key "TSFE"

Hi,

In Typo3 11.5.16 and PHP8, if you first select a page in the pagetree and then click "Redirects" in the tool menu you get:
PHP Warning: Undefined array key "TSFE" in /var/www/typo3.sol.lu.se/typo3conf/ext/jumpurl/Classes/JumpUrlProcessor.php line 41
Not a huge problem but annoying. Changing line 41 to:
$this->frontendController = $typoScriptFrontendController ?? ($GLOBALS['TSFE'] ?? null);
solves the problem.

Kind regards

Tomas

Generating typolinks from the backend, PHP 8 warning / exception

If I have a backend module which generates typolinks, for example via fluid template:

<f:link.typolink parameter="{target}" />

and have EXT:jumpurl installed, I end up with an Exception when running with PHP 8:

#1476107295 TYPO3\CMS\Core\Error\Exception
PHP Warning: Undefined global variable $TSFE in /app/html/typo3conf/ext/jumpurl/Classes/JumpUrlProcessor.php line 41
...
in /app/html/typo3conf/ext/jumpurl/Classes/JumpUrlProcessor.php line 41

This happens in the registered typolink hook ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlProcessors']).

Jumpurl causes PHP warnings about undefined array key while null coalescing

Hello,

using jumpurl in a freshly updated typo3 installation throws warnings.

System configuration: jumpurl 8.0.3, typo3 11.5.17 and PHP 8.0.

Warning message: Core: Error handler (FE): PHP Warning: Undefined array key "jumpurl" in /www/htdocs/w0063ec2/cm3/typo3conf/ext/jumpurl/Classes/Middleware/JumpUrlHandler.php line 60

To me, the typecast in line 60 appears to be guilty.
Putting braces around the expression with the null coalescing operator removes the warnings.

$jumpUrl = (string) ( $request->getQueryParams()['jumpurl'] ?? '');

Kind regards
peter

TypeError in backend module "redirects" with "jumpurl" installed

TYPO3 10.4.1
redirects 10.4.1
jumpurl 8.0.0
PHP 7.4

Redirects with an external URL in field target throw the following error in backend module redirects:

(1/1) TypeError

Return value of FoT3\Jumpurl\JumpUrlProcessor::getTypoScriptFrontendController() must be an instance of TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController, null returned

in [...]/public/typo3conf/ext/jumpurl/Classes/JumpUrlProcessor.php line 208

protected function getTypoScriptFrontendController(): TypoScriptFrontendController
{
    return $this->frontendController ?? $GLOBALS['TSFE'];
}

jumpurl error with typoscript links

Hi all,
A recently upgraded a typo3 6.2 LTS installation to 7.6 LTS and installed jumpurl because direct_mail seems to need it. Since this update the log show a lot of jumpurl errors:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1359987599: The calculated Jump URL hash ("juHash") did not match the submitted "juHash" query parameter.
Exception thrown in file /.../typo3conf/ext/jumpurl/Classes/JumpUrlHandler.php in line 221.
Requested URL: http://augustana.de/aktuelles/ankuendigungen.html?jumpurl=http%3A%2F%2Fahs.dabis.cc

The link can be reached via a Dropdown in the header of all pages: "Quicklinks/Bibliothekskatalog"
When I click on that link the page opens without problems.

As far as I see those errors occur with links generated via typoscript.
I don't understand what makes those errors occur (since clicking in the frontend works) and how I can prevent them.

Any help appreciated,
Andrea

Request: Possibility to disable jumpurl functionality for external links

Using jumpurl with TYPO3 7.6 it is not possible to get redirected to an external URL when jumpurl is enabled. File links on the other hand are working perfectly (with setting "secure = 1").
This is the exception thrown by TYPO3 for an external link:
#1294585194: The requested file was not allowed to be accessed through Jump URL. The path or file is not allowed.

I have added an additional condition to the JumpUrlProcessor::isEnabled() function on my own checking for links with context UrlProcessorInterface::CONTEXT_EXTERNAL and a globally disabled new option "config.jumpurl_external_disable". Calling this function with another parameter "url" from the process() function it is possible to disable the generation of jumpurl URLs for external links completely:

// If we have an external link and jumpurl is globally disabled for external links we disable it
if (
  $context === UrlProcessorInterface::CONTEXT_EXTERNAL
  && $this->getTypoScriptFrontendController()->config['config']['jumpurl_external_disable']
) {
  $enabled = false;
}

Would it be possible to add this new configuration parameter and functionality in a future version?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.