maikschneider / bw_captcha

TYPO3 extension that adds a captcha element with audio support for the TYPO3 form component. The captcha generation uses Gregwar/Captcha, no Google or 3rd party includes.
6 stars 6 forks source link

Loading font files from storage may not work when absolute paths are used #64

Open saitho opened 5 months ago

saitho commented 5 months ago

Just a small heads up: TYPO3 12.1 introduces a new feature in TypoScript setup to enforce absolute URLs. config.forceAbsoluteUrls = 1

When loading fonts from file storage, there may be issues with this line, as getPublicUrl() then returns an absolute path: https://github.com/maikschneider/bw_captcha/blob/development/Classes/Utility/CaptchaBuilderUtility.php#L102

$randomFontFile = $resourceFactory->retrieveFileOrFolderObject($fontFiles[0])?->getPublicUrl() ?? '';
$randomFontFile = Environment::getPublicPath() . $randomFontFile;

We're currently enabling this feature, but are not using font files from storage. I just came across this when checking for side effects.

maikschneider commented 5 months ago

Hey @saitho, thank you very much for the warning! I will definitely look into this and implement a check. Cheers!