CodeIgniter4
CodeIgniter4 copied to clipboard
Bug: How can I know which browser name is the request from?
PHP Version
8.1
CodeIgniter4 Version
4.5.0
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
No response
What happened?
When I call the method CodeIgniter\HTTP\UserAgent->isBrowser with 'Spartan', if the client browser agent string matched the keyword 'Edge', the method will return false.
Steps to Reproduce
Call CodeIgniter\HTTP\UserAgent->isBrowser with 'Spartan', and request the server by a browser which's agent string includes 'Edge'.
Expected Output
method should return true
Anything else?
By viewing the source code,I found this method only check whether the param $key is existed in user agent string, but not compare it with the property 'browser'. It's not compliant with description in the manual, which say the param $key is 'Optional browser name'. Maybe you should change the statement "if($key === null)
" to "if ($key === null||$this->browser === $key)
"?
The other two method 'isRobot' and 'isMobile' also have the same problem.