Bug #65608

BaseURL is wrong in Frontend when using RealURL with config.absRefPrefix

Added by M. Stichweh over 4 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
RTE (rtehtmlarea + ckeditor)
Target version:
-
Start date:
2015-03-09
Due date:
% Done:

0%

TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
no-brainer
Is Regression:
No
Sprint Focus:

Description

The baseURL is wrong when the RTE editor is embeded in Frontend if RealURL is used and config.absRefPrefix is set instead of setting config.baseUrl. The problem is, if absRefPrefix is set to '/' for example, the baseURL is set by JavaScript using document.baseURI (or by fetching the base-Tag on IE). But since no base-Tag is set the full RealURL path is used as baseURL, so the base-Tag and the CSS resource pathes are wrong in the RTE iframe.
The baseURL should by set as parameter by PHP when building the "RTEarea[editornumber]" JavaScript configuration array instead of setting it in JavaScript. Then it could by set using config.baseURL or config.absRefPrefix maybe with the help of the typolink logic.


Related issues

Related to TYPO3 Core - Bug #65705: baseURL determination of EXT:rtehtmlare fails in edge case Closed 2015-03-12
Related to TYPO3 Core - Bug #79568: baseURL determination of EXT:rtehtmlarea fails in frontend editing Closed 2017-01-31

Associated revisions

Revision a8c6b34b (diff)
Added by Pierrick Caillon over 2 years ago

[BUGFIX] Wrong computed baseURL with FE editing RTE

Frontend editing button for editing a content now
url encode the return URL. The HTMLAREA baseURL
computation now excludes query parameters and anchor
from the document URL.

Resolves: #79568
Related: #65705
Related: #65608
Releases: master
Change-Id: I57ae5257ab62cff1398a0b2d088fe7ba3b126c76
Reviewed-on: https://review.typo3.org/51489
Tested-by: TYPO3com <>
Reviewed-by: Mona Muzaffar <>
Tested-by: Mona Muzaffar <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

Revision 5df7e2c9 (diff)
Added by Jigal van Hemert about 2 years ago

[BUGFIX] Wrong computed baseURL with FE editing RTE

Frontend editing button for editing a content now
url encode the return URL. The HTMLAREA baseURL
computation now excludes query parameters and anchor
from the document URL.

Resolves: #79568
Related: #65705
Related: #65608
Releases: 7.6
Change-Id: I57ae5257ab62cff1398a0b2d088fe7ba3b126c76
Reviewed-on: https://review.typo3.org/52142
Tested-by: TYPO3com <>
Reviewed-by: Stefan Neufeind <>
Reviewed-by: Elmar Hinz <>
Tested-by: Riccardo De Contardi <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

History

#1 Updated by M. Stichweh over 4 years ago

I fixed it with adding this in registerRTEinJS() in Typo3 4.7:

if( $GLOBALS['TSFE']->config['config']['absRefPrefix'] && !$GLOBALS['TSFE']->config['config']['baseURL'] &&
    t3lib_extMgm::isLoaded( 'realurl' ) )
{    
    $baseURL = $GLOBALS['TSFE']->config['config']['absRefPrefix'];
    if( !preg_match( '@^https?://@i', $baseURL ) )
    {
        if( strpos( $baseURL, '/' ) === 0 )
        {
            $baseURL = substr( $baseURL, 1 );
        }
        $baseURL = t3lib_div::getIndpEnv( 'TYPO3_SITE_URL' ) . $baseURL;
    }
    $configureRTEInJavascriptString .= '
        RTEarea[editornumber].baseURL = "' . $baseURL . '";';
}

A solution could be adding the code in getRteInitJsCode():

$baseURLConfig = '';
if( $GLOBALS['TSFE']->config['config']['absRefPrefix'] && !$GLOBALS['TSFE']->config['config']['baseURL'] &&
    t3lib_extMgm::isLoaded( 'realurl' ) )
{    
    $baseURL = $GLOBALS['TSFE']->config['config']['absRefPrefix'];
    if( !preg_match( '@^https?://@i', $baseURL ) )
    {
        if( strpos( $baseURL, '/' ) === 0 )
        {
            $baseURL = substr( $baseURL, 1 );
        }
        $baseURL = t3lib_div::getIndpEnv( 'TYPO3_SITE_URL' ) . $baseURL;
    }
    $baseURLConfig .= '
        RTEarea[0].baseURL = "' . $baseURL . '";';
}

return '
    if (typeof(RTEarea) == "undefined") {
        RTEarea = new Object();
        RTEarea[0] = new Object();' .
        $baseURLConfig . '
...

And using the current JavaScript method only if baseURL is not set:

HTMLArea.Config = function (editorId) {
...
    this.baseURL = HTMLArea.baseURL;
    if( !this.baseURL )
    {
            // BaseURL to be included in the iframe document
        this.baseURL = document.baseURI;
    }
...

#2 Updated by M. Stichweh over 4 years ago

Because the absRefPrefix is automatically prepanded to the CSS pathes on page rendering it is applied twice with this solution. So I modified the code as follows:

if( $GLOBALS['TSFE']->config['config']['absRefPrefix'] && !$GLOBALS['TSFE']->config['config']['baseURL'] && 
    t3lib_extMgm::isLoaded( 'realurl' ) )
{
    $baseURL = $GLOBALS['TSFE']->config['config']['absRefPrefix'];
    if( !preg_match( '@^https?://@i', $baseURL ) )
    {
        if( strpos( $baseURL, '/' ) === 0 )
        {
            $baseURL = t3lib_div::getIndpEnv( 'TYPO3_REQUEST_HOST' );
        }
        else
        {
            $baseURL = t3lib_div::getIndpEnv( 'TYPO3_SITE_URL' );
        }                        
    }
...

#3 Updated by Lorenz Ulrich over 4 years ago

Could you please try if this patch could fix your issue:
https://review.typo3.org/#/c/37799/

#4 Updated by Benni Mack about 4 years ago

  • Target version changed from 7.2 (Frontend) to 7.4 (Backend)

#5 Updated by Susanne Moog about 4 years ago

  • Target version changed from 7.4 (Backend) to 7.5

#6 Updated by Benni Mack almost 4 years ago

  • Target version changed from 7.5 to 7 LTS

#7 Updated by Riccardo De Contardi almost 2 years ago

  • Status changed from New to Closed
  • Target version deleted (7 LTS)

Sorry but this will not be fixed for version 7.6.x (that is in its "priority bugfix" phase) and does not affect 8.7.x, so I think I can close it for now.

If you think that this is the wrong decision or experience the issue again, please reopen it or open a new issue wit a reference to this one. Thank you.

Also available in: Atom PDF