I wouldn't really want to bother you here, but as I don't have a mac I cannot test this.
I made a browser sniffing class (I know it's bad but it works well and is not the point).
This all works fine, however my colleague said there was a bugg on a website I recently did.
All I would like to know / see is if there is a link to any website that has the Safari 7 useragent string documented / raw or if someone could post the Safari 7 UA string here ($_SERVER['HTTP_USER_AGENT'] in PHP).
I checked for this on google and websites as useragentstring.com, but cant get the UA from there either.
Thanks in advance.
Found it:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9) AppleWebKit/537.71 (KHTML, like Gecko) Version/7.0 Safari/537.71
Related
TL;DR: Safari on Desktop sent a single request with an iPhone user agent and without cookies, and we don't know why. It uses FOUR different user agents.
I was using Safari 16.1 on macOS Ventura 13.1 to test a website that I built.
I found a strange request with an iPhone User Agent string in the server access log.
This request did not include any cookies, causing my session to end.
I am convinced that the request came from my browser because:
It is from my IP address, and I'm the only one here.
The request was 1 second before a request that I know I made, for the same URL.
The URL is several steps into a checkout process, so it is unlikely to be reached any other way (e.g. bots).
Requests before and after it had my expected desktop user agent (see screenshot).
But what is strange is:
There is only one request logged with the iPhone user agent string.
There are no iPhones or other Apple devices at this IP address, just a MacBook Air.
Safari can emulate other user agents, but I have never used that feature in Safari.
I did have the Safari Web Inspector open at the time, to watch a cookie.
The URL outputs some content with a JavaScript redirect, so it is actually not possible to stay on it to refresh it.
So why did desktop Safari change the user agent string to iPhone for a single request?
Is there some keyboard shortcut for switching user agent that I could have pressed accidentally?
Or is this a known behaviour of Safari? (like this other surprising user agent change)
UPDATE: During a short session, after updating to macOS Ventura 13.2 and Safari 16.3, Safari used 4 different user agents.
1 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15"
2 "Safari/18614.4.6.1.5 CFNetwork/1404.0.5 Darwin/22.3.0"
3 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)"
4 "Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1"
(1) is the main user agent reported by most tools.
(2) requests apple-touch-icons, and I understand it.
(3) is a little shorter than the main one, and made only 3 simultaneous requests at the start of my session.
(4) contains "iPhone", and made 3 simultaneous requests at the same time as (3).
I'd like to use Chrome to emulate different devices to run my frontend tests on different emulators. in the documentation, I found the following example
And driver.emulateDevice(375, 812, 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1')
where can I get a list of different options?
That is completely up to you, Karate just takes the string you provide and uses it "as is".
For further research into what that string is all about, you can refer this: https://wicg.github.io/ua-client-hints/
Is there a way to identify if a HTTP request was send using Selenium?
For example if Selenium adds any request header, cookie or equivalent?
I tried looking at the User Agent, but it didn't reveal anything about Selenium:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
I noticed that HTTP_X_FORWARDED_FOR gets set if Selenium is being used:
HTTP_X_FORWARDED_FOR => 0:0:0:0:0:0:0:1%0
Nope. Selenium doesn't mark its requests with anything.
Why in the world is this the webkit user agent:
Mozilla/5.0 (Windows NT 6.0; WOW64) AppleWebKit/534.27+ (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27
Why not:
Webkit/5.04 (Windows NT 6.0; WOW64) AppleWebKit/534.27+ (KHTML, like Gecko) Safari/533.20.27
Thanks for clearing this up :)
It really is a left over from the early days of Web. Many sites were only compatible with Netscape Navigator, which was the dominant browser at that point, and so what they did was to sniff the User-Agent for the "Mozilla/*" part. When IE showed up, MS wanted those websites to work in their browser as well, so they went for pretending they are Mozilla as well. And so did all the browsers that popped up later on, including WebKit-based ones. And it doesn't seem like that artifact is going away anywhere soon as still many old sites do that type of sniffing and for browsers dropping this convention would probably mean breaking thousands of sites.
It's a throwback to the browser wars, the browser is identifying as a 'Mozilla Compatible' agent.
When someone accesses a site via a WebView in an iPhone app, is there a reliable way (JavaScript or server-side) to tell what app is being used? It seems like the user agent string can tell me if it's from Safari or not, but not what precise app is being used if it's not Safari, unless a custom user agent has been specified by the app's programmer (which is not often).
I'd like to be able to tell more precisely what exact app is being used in order to serve [slightly] customised content. The identifier doesn't need to be human-readable, just app-sepcific (so e.g. a bundle ID would be fine).
Example (and not useful) user agents:
From Safari: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16"
Most Apps:
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Mobile/7D11"
I tried to write just "Nope", but answers are required to be at least 15 characters long...