Issue Bug Rejected

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

Jonas Lippuner 01/14/12, 21:08 updated 03/25/20, 16:03

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.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.