I think it's interesting to note that the majority of web developers for at least the last 10 years have realised that the User Agent is a very flaky way to determine capability. It is almost universally ignored now (with a few enterprise-level exceptions) So the usual solution is feature detection, where the javascript and/or CSS learns the true capabilities of the browser, and switches features on and off according…
Sadly there are situations where "feature detection" is not really an option e.g. when safari does something really weird and you need a special codepath for it server-side (like the video player not working if the server doesn't support content-range, so you have to not send a video to safari in that case).
Yeah, I got bitten by that one too. Pretty darn annoying especially because Safari doesn't tell you what is wrong.