Project

General

Profile

Actions

Bug #65608

closed

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

Added by M. Stichweh over 9 years ago. Updated about 7 years ago.

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

0%

Estimated time:
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 2 (0 open2 closed)

Related to TYPO3 Core - Bug #65705: baseURL determination of EXT:rtehtmlare fails in edge caseClosed2015-03-12

Actions
Related to TYPO3 Core - Bug #79568: baseURL determination of EXT:rtehtmlarea fails in frontend editingClosed2017-01-31

Actions
Actions #1

Updated by M. Stichweh over 9 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;
    }
...
Actions #2

Updated by M. Stichweh over 9 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' );
        }                        
    }
...
Actions #3

Updated by Lorenz Ulrich over 9 years ago

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

Actions #4

Updated by Benni Mack over 9 years ago

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

Updated by Susanne Moog over 9 years ago

  • Target version changed from 7.4 (Backend) to 7.5
Actions #6

Updated by Benni Mack about 9 years ago

  • Target version changed from 7.5 to 7 LTS
Actions #7

Updated by Riccardo De Contardi about 7 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.

Actions

Also available in: Atom PDF