Closed as not planned
Description
Symfony version(s) affected
6.4+
Description
When using a TRUSTED_PROXIES with a netmask (i.e. 192.168.1.0/24) and php 8.3 every request fails with an exception
Uncaught PHP Exception TypeError: "substr_compare(): Argument #4 ($length) must be of type ?int, string given" at IpUtils.php line 105
How to reproduce
Symfony 6.4 project using php 8.3 and TRUSTED_PROXIES configured with a IP range (i.e. 192.168.1.0/24)
Possible Solution
Cast the extracted netmask from string to int
Additional Context
Full stack trace
Uncaught PHP Exception TypeError: "substr_compare(): Argument #4 ($length) must be of type ?int, string given" at IpUtils.php line 105 {"exception":"[object] (TypeError(code: 0): substr_compare(): Argument #4 ($length) must be of type ?int, string given at C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\http-foundation\\IpUtils.php:105)
[stacktrace]
#0 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\http-foundation\\IpUtils.php(105): substr_compare()
#1 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\http-foundation\\IpUtils.php(59): Symfony\\Component\\HttpFoundation\\IpUtils::checkIp4()
#2 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\http-foundation\\Request.php(1999): Symfony\\Component\\HttpFoundation\\IpUtils::checkIp()
#3 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\http-foundation\\Request.php(1109): Symfony\\Component\\HttpFoundation\\Request->isFromTrustedProxy()
#4 C:\\Riviera\\SYS\\MV3\\vendor\\nelmio\\security-bundle\\src\\EventListener\\ForcedSslListener.php(58): Symfony\\Component\\HttpFoundation\\Request->isSecure()
#5 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\event-dispatcher\\EventDispatcher.php(260): Nelmio\\SecurityBundle\\EventListener\\ForcedSslListener->onKernelRequest()
#6 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\event-dispatcher\\EventDispatcher.php(220): Symfony\\Component\\EventDispatcher\\EventDispatcher::Symfony\\Component\\EventDispatcher\\{closure}()
#7 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\event-dispatcher\\EventDispatcher.php(56): Symfony\\Component\\EventDispatcher\\EventDispatcher->callListeners()
#8 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\http-kernel\\HttpKernel.php(157): Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch()
#9 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\http-kernel\\HttpKernel.php(76): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw()
#10 C:\\Riviera\\SYS\\MV3\\vendor\\symfony\\http-kernel\\Kernel.php(197): Symfony\\Component\\HttpKernel\\HttpKernel->handle()
#11 C:\\Riviera\\SYS\\MV3\\public\\index.php(46): Symfony\\Component\\HttpKernel\\Kernel->handle()
#12 C:\\Riviera\\SYS\\MV3\\vendor\\autoload_runtime.php(24): {closure}()
#13 C:\\Riviera\\SYS\\MV3\\config\\bootstrap.php(5): require_once('...')
#14 C:\\Riviera\\SYS\\MV3\\public\\index.php(7): require('...')