Bug #65608
closedBaseURL is wrong in Frontend when using RealURL with config.absRefPrefix
0%
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.
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; } ...
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' ); } } ...
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/
Updated by Benni Mack over 9 years ago
- Target version changed from 7.2 (Frontend) to 7.4 (Backend)
Updated by Susanne Moog over 9 years ago
- Target version changed from 7.4 (Backend) to 7.5
Updated by Benni Mack about 9 years ago
- Target version changed from 7.5 to 7 LTS
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.