Skip to content

Conversation

@liviuconcioiu
Copy link
Collaborator

@liviuconcioiu liviuconcioiu commented Mar 10, 2025

#7981 (comment)

Mobile Safari version is always the iOS / iPadOS version

https://developer.apple.com/documentation/safari-release-notes

This should also close #7979.

if (\in_array($this->osName, ['iOS', 'iPadOS']) && '' !== $this->osVersion && 'Mobile Safari' === $name) {
$version = $this->osVersion;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just this condition will be enough for us?

        // Mobile Safari version is always the iOS / iPadOS version
        // See https://developer.apple.com/documentation/safari-release-notes
        if ('Mobile Safari' === $name && '' === $version) {
            \preg_match(
                '~iP(?:hone|ad) ?OS ([0-9]{1,2})[_.]([0-9]{1,2})(?:[_.]([0-9]{1,2}))?~i',
                $this->userAgent,
                $osMatch
            );
            if ($osMatch) {
                $version = \implode('.', \array_filter([$osMatch[1], $osMatch[2], $osMatch[3] ?? null]));
            }
        }
        

Then our browser parser will not depend on OS parser.
This will also work correctly when using BrowserParser alone.

Copy link
Collaborator Author

@liviuconcioiu liviuconcioiu Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just this condition will be enough for us?

Then our browser parser will not depend on OS parser. This will also work correctly when using BrowserParser alone.

It will not work because there are user agents like:

MobileSafari/9537.53 CFNetwork/672.1.13 Darwin/13.1.0

Another way I tried to do this is was to change the browser version with os version in DeviceDetector.php, with only a few lines, but then I encountered the failed tests, which use only the BrowserParser.

I'm happy with any other suggestions, if we can do this, and tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

new Bots report

2 participants