News for hackers. Stuff that matters.
Re:User Agent Changes by pornel on Thursday December 12, 2019 @07:33PM (#21778069)
Congratulations Google, you did it! You killed the User-Agent header.

The HTML spec already requires all browsers to report themselves as Netscape in the Netscape-era `navigator` object:

        appCodeName - Must return the string "Mozilla".
        appName - Must return the string "Netscape".
        product - Must return the string "Gecko".
So a few more "oopses" from Google products and the next spec will end up saying:

       User-Agent - Must be equal to the string "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79"
Re:User Agent Changes by chrismorgan on Thursday December 12, 2019 @08:13PM (#21778259)
For reference, https://html.spec.whatwg.org/multipage/system-state.html#cli.... Browsers are essentially required to pretend to be Firefox from 2010, or Chrome from 2003 (!), or Safari from 2003—all while pretending to be Firefox or its predecessor in a couple of other ways. I find it very amusing.
Re:User Agent Changes by kccqzy on Thursday December 12, 2019 @10:31PM (#21778950)
Chrome didn't exist in 2003. The year 2003 is because Safari existed then, but Google forked WebKit later on.
Re:User Agent Changes by naniwaduni on Thursday December 12, 2019 @08:56PM (#21778498)
Some context: 20030107 is Safari's first public release date.
Re:User Agent Changes by bryanrasmussen on Friday December 13, 2019 @03:01AM (#21779900)
this reads like an April 1st spec, "The taintEnabled() method must return false" - hur hur hur.
Re:User Agent Changes by stickfigure on Friday December 13, 2019 @12:53AM (#21779413)
the next spec will end up saying...Must be equal to the string...

This is exactly the right way to solve the problem. The UA header isn't going away because of Legacy. Pin it to an arbitrary generally accepted value and be done with it. The best part about this is that any client-side developer can implement this solution unilaterally... and Vivaldi now has.

Re:User Agent Changes by stephenr on Friday December 13, 2019 @01:00AM (#21779440)
Assuming that the problem here is people doing UA sniffing, the problem, like with people doing glue sniffing, is to stop people sniffing the UA (or glue) - not to make the UA (or glue) unusable for it's intended purpose.

Have you ever used a service that shows things like your active sessions, login attempts etc? Notice how they basically all show you what kind of device and usually what browser the session/login is from, with a date time and usually location?

If everyone pretends to be Chrome what's the fucking point any more? "You logged in from Chrome on Tuesday the 3rd at 8am". "Well no I fucking didn't, I guess I better go reset my damn passwords again".

Re:User Agent Changes by denormalfloat on Friday December 13, 2019 @01:36AM (#21779587)
There are wrong reasons to sniff the UA string, and less wrong reasons. If a Browser has a bug that gets fixed in later versions, sites have to sniff the UA string to do the right thing. For example, a browser bug may cause people to see an error, and the they are using an old version of the browser. The right thing to do is to upgrade, but how to tell? When you are subject to the bugs of some other code, and which are skewed across different versions of the software, the most reasonable way to work around it is by UA sniffing.
Re:User Agent Changes by zeta0134 on Friday December 13, 2019 @02:48AM (#21779852)
I would have bought this argument a decade ago, but at this stage the number of site users not doing some form of automatic updates on their browser should be in the minority. The problems user agents were designed to solve back in the Netscape Navigator days have since been standardized using much better signals, and the odd standards compliance bug here and there isn't really justification for something as weak and unreliable as a user agent string.

I say kill it. Fix it to some static value and require new sites moving forward to do proper feature detection if they really care to work around standards bugs or use experimental new features.

Re:User Agent Changes by dgoldstein0 on Friday December 13, 2019 @03:30AM (#21780017)
The core web features don't have such bugs anymore for all practical purposes, but newer apis do. Content security policy in particular has a lot of bugs especially around features in v2 and v3 of the spec, when they were first implemented in chrome / Firefox often took a few major versions to get right. I think I've seen similar hacks around use of newer crypto apis. The alternative is to wait 2-3 years between the release of a new api by all major browsers and actually using it.
Re:User Agent Changes by Zarel on Friday December 13, 2019 @04:50AM (#21780358)
Sadly, feature detection is still impossible for many features.

For instance, the only way to detect `contentEditable` support is through user-agent sniffing. Many versions of Android Chrome and iOS Safari will happily report that they support `contentEditable` and then refuse to make the content editable.

I'm actually struggling with a similar issue right now: there's no way to detect an on-screen keyboard, so there's no way to focus a textbox only if it wouldn't cover up the screen with an on-screen keyboard (which is pretty important for chat apps). The best you can do involves a lot of hacks, including UA sniffing.

Re:User Agent Changes by dgoldstein0 on Friday December 13, 2019 @05:29AM (#21780522)
Ouch. Wasn't aware of those. But still not surprised there are edge cases out there.

If I look hard enough, I can always find places where different browser behaviors differ. For instance, I once discovered that the maximum top value I could put a position absolute div within a position relative div was around 20 million px in chrome but only 1.53 million in IE (if my memory serves). This was at least fixable by stacking multiple divs for every 1.5 million pixels I wanted to lay out.

But for every quirk like this that's possible to work around by coding to the lowest common denominator, there's another somewhere that you just can't. I recall doing another project which involved trying to pop open a mobile app to view content; and it was supposed to switch to the store to prompt you to install if you didn't have the app. At the time this involved different hacks for iOS Safari and Android chrome. Behaviors that differed included what happened when you navigate to a scheme with no handler (in chrome, the previous page kept running), and whether the scheme could trigger the app from an iframe (which was blocked in chrome but not Safari iirc). And handing off state to the app during the install flow was simple on Android, but on iOS required another pile of hacks. Whole thing ended up an overcomplicated mess, but we ended up pretty good ux for the intended flows. This was 2014 so the situation is probably better today - I think iOS Safari added some meta tags that are targeted to very similar use cases.

Re:User Agent Changes by NieDzejkob on Friday December 13, 2019 @11:01AM (#21782699)
If you don't mind me asking, why are you dealing with million-pixel distances? What problems do they solve?
Re:User Agent Changes by chrismorgan on Friday December 13, 2019 @09:09PM (#21787317)
Probably the most common use case for such things is progressively-rendered/-loaded lists, where you know the number of items and the height of each item in the list, so that you can reserve all the space and provide a meaningful scrollbar, and have a limited number of children absolutely positioned on screen at any given time.

This gives a far better experience than infinite scrolling (which has no meaningful scrollbar, so you can’t jump to the end or an arbitrary point in the middle) or pagination (which is just generally painful once you want something not at the start).

We do this in Fastmail’s webmail, and have put in workarounds for overly-tall elements breaking browsers. https://github.com/fastmail/overture/blob/41cdf36f3e7c8f0dd1... lists them, including some values at which things break. (Actually, IE doesn’t allow containers anywhere near that tall, capping effective values much earlier, with the consequence that you can’t access things near the end of the list. But the problem was that once you get much larger still, it starts ignoring the values you specify altogether, which would break the entire technique.)

For us, the most common height of each email’s entry in the list is 51px; at that, 400,000 emails is enough to get to 20,400,000px high, which is enough to break both IE and Firefox (not sure about Chrome or Safari, I’ve never actually tested it; their failure mode may well just be different, limiting numbers instead of ignoring them).

400,000 emails in a mailbox isn’t all that common, but it does happen.

Re:User Agent Changes by dgoldstein0 on Friday December 13, 2019 @05:31AM (#21780527)
Oh the other thing was that we were using an https url override on Android and the custom scheme was primary iOS. And the iOS 8 or 9 added the ability for apps to handle https urls, which could be used to simplify our iOS nonsense. But not all of it.
Re:User Agent Changes by wongarsu on Friday December 13, 2019 @05:33AM (#21780535)
That depends on your user base. For example [1] sees about 10-20% of Chrome and Firefox users on some notably "outdated" version. If your demographic skews towards enterprise users that seems very plausible, large companies regularly hold updates back until they are tested or use extended support releases.

1: https://www.stetic.com/market-share/browser/

Re:User Agent Changes by CM30 on Friday December 13, 2019 @05:55AM (#21780631)
For most CSS and JavaScript incompatibility issues, the way to check doesn't require UA sniffing at all. You merely check if the browser supports said feature by looking for whether the supports media query runs or if the new method is available at all.

https://developer.mozilla.org/en-US/docs/Web/CSS/@supports

Re:User Agent Changes by silverwind on Friday December 13, 2019 @07:33AM (#21780993)
@supports is often unreliable for CSS features. At least in Blink, it acts more as a "valid syntax" check then a "supported feature" check and for some reason Blink's CSS engine recognizes many new CSS features as valid syntax while not actually supporting them.
Re:User Agent Changes by namibj on Friday December 13, 2019 @10:03AM (#21782151)
I for one would serve adapted css that is matched to the browser. Due to vendor prefixes there is unfortunately some mandatory bloat for a cross-browser stylesheet.

It would also skip polyfills when those aren't needed.

Re:User Agent Changes by bryanrasmussen on Friday December 13, 2019 @03:05AM (#21779916)
obviously what will happen with those services that need to know what browser you logged in at is they will do more vigorous capability based checking to determine your browser - sort of like how css used to have all sorts of hacks to target particular browsers.
Re:User Agent Changes by stephenr on Friday December 13, 2019 @03:13AM (#21779942)
... You're suggesting that rather than using the user agent, to identify.. the user agent, because people abused user agent strings to detect features... sites will now need to detect features and maintain a complete matrix of the features every browser and version implements, and determine the browser name, from the features it supports?

You realise how ridiculous that sounds right?

Or did you just completely misunderstand what I was talking about:

Some sites (and I've built some that do this) will show e.g. login history or account activity for users, and might say e.g. "Logged in from London using Chrome v52 on a Windows 8 PC on Tuesday at 10pm".

It's very much for human consumption.

Re:User Agent Changes by bryanrasmussen on Friday December 13, 2019 @03:45AM (#21780076)
Yes I realize how ridiculous that sounds, but on the other hand if the old way of doing it will no longer work and people need to do it they will find another way. Generally technically less nice to work with and all sorts of other attendant problems but that's the breaks. I believe this is a bad idea, but it looks like the bad idea is coming to pass.

I mean considering that if browser makers go along with this way of doing it, necessitating the hacky way of finding out what browser one is using. I think they will go along with it, but maybe also reason will prevail?

I suppose what will happen if this gets widespread is something like modernizr to detect all possible features (also those in development pipelines), and then take those features and use something like the caniuse api https://www.npmjs.com/package/caniuse-api to give you what browsers are possible for each feature, leading to some point where you can narrow it down to browser name, version.

Re:User Agent Changes by basicplus2 on Saturday December 21, 2019 @08:18PM (#21854462)
I vote this comment of the month
Re:User Agent Changes by Vinnl on Friday December 13, 2019 @08:01AM (#21781146)
The problem there is that websites can no longer decide what content and workarounds to serve based on the user agent. Feature detection is great, but not a solution for things that need to happen server-side.
Re:User Agent Changes by bambax on Friday December 13, 2019 @04:29AM (#21780268)
If every browser uses the same string then it's useless/pointless; why not get rid of the UA altogether??
Re:User Agent Changes by sfilipov on Friday December 13, 2019 @04:34AM (#21780289)
To prevent existing code that relies on it from breaking.
Re:User Agent Changes by juped on Friday December 13, 2019 @02:25AM (#21779774)
And don't replace it. (Someone will replace it.)
Re:User Agent Changes by ErikAugust on Thursday December 12, 2019 @09:57PM (#21778777)
Re:User Agent Changes by TylerE on Thursday December 12, 2019 @09:38PM (#21778704)
As soon as you trust the client, it's game over. Period.
Re:User Agent Changes by eru on Thursday December 12, 2019 @11:16PM (#21779106)
There's more than one kind of trust.

You should totally trust your client to show stuff to the user. And you can generally trust your client when giving you user data, in the sense that you can trust that the data came from the user. (Unless the client is hacked by third-parties or buggy.)

Basically, you can trust your client as much as you can trust your user. Not more.

Re:User Agent Changes by bowmessage on Thursday December 12, 2019 @09:37PM (#21778698)
Interesting perspective; one could argue that the creators of non-web-standards-compliant browsers are really to blame here, forcing webdevs to branch / gate so often on the UA header. Agreed that it is really becoming dead, though.
Re:User Agent Changes by gbear605 on Thursday December 12, 2019 @10:23PM (#21778909)
The whole point of the article is that a number of sites (Google, Facebook, Netflix) are returning invalid sites because the browser is Vivaldi, not to make the site work with Vivaldi, but to make Vivaldi not work. It’s entirely the developer’s fault, not the browser’s.
Re:User Agent Changes by bowmessage on Thursday December 12, 2019 @10:49PM (#21779014)
Sure, but developers were forced down this path due to IE6 et. al. not respecting an open-standards-compliant grammar for HTML, JS, etc.
Re:User Agent Changes by GoblinSlayer on Friday December 13, 2019 @08:58AM (#21781515)
What you can't do on IE6 without user agent sniffing?