Project

General

Profile

Actions

Bug #33197

closed

t3lib_div returns wrong value for TYPO3_SITE_SCRIPT if the request URL contains percent-encoded characters

Added by Jonas Lippuner over 12 years ago. Updated about 4 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Start date:
2012-01-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.6
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

I have a site hosted under www.example.com/~user/ and I am using RealURL. Accessing www.example.com/~user/ from a browser works fine, but I found that it does not work when I click on the link www.example.com/~user/ in a PDF file opened in Adobe Reader. The reason is that Adobe Reader will actually open the link www.example.com/%7Euser/ where ~ is encoded as %7E. As a result, t3lib_div will return a wrong value for t3lib_div::getIndpEnv('TYPO3_SITE_SCRIPT');, which ultimately passes a wrong value of siteScript to RealURL, breaking everything.

The problem is, that it is assumed that the TYPO3_SITE_URL has the same number of characters as the site URL specified in TYPO3_REQUEST_URL. But this not true if the original request URL contains percent-encoded characters. My quick and dirty fix is to do

$request_url = str_replace(array("%7e", "%7E"), "~", t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'));
$retVal = substr($request_url,strlen(t3lib_div::getIndpEnv('TYPO3_SITE_URL')));

instead of

$retVal = substr(self::getIndpEnv('TYPO3_REQUEST_URL'), strlen(self::getIndpEnv('TYPO3_SITE_URL')));

in the file class.t3lib_div.php.

Obviously, this is not a general solution of the problem. I think the best solution would be to automatically decode all percent-encoded characters in the request URL at an early stage. I am not familiar enough with Typo3 to be able to suggest a specific fix or where it should be implemented.

Actions

Also available in: Atom PDF