#11229 closed bug (wontfix)
iOS UIWebView detected as mozilla instead of webkit
Reported by: | salomvary | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery loaded into iOS applications' embedded web browser view (UIWebView) detects the browser as mozilla instead of webkit. Example: links followed from Facebook app's news feed.
Expected:
$.browser.webkit === true
Got:
$.browser.webkit === undefined
$.browser.mozilla === true
UserAgent tested:
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_0_1 like Mac OS X; en_US) AppleWebKit (KHTML, like Gecko) Mobile [FBAN/FBForIPhone;FBAV/4.1;FBBV/4100.0;FBDV/iPhone4,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/5.0.1;FBSS/2; FBCR/Carrier;FBID/phone;FBLC/en_US;FBSF/2.0]"
Change History (3)
comment:2 Changed 11 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I agree. Feature detection would definitely be your best bet. Since jQuery.browser is deprecated and this is a pretty rare situation, we aren't likely to fix it. Trying to craft a regexp in order to "fix" these situations is always hit or miss.
comment:3 Changed 11 years ago by
I can confirm that this is only broken in Facebook's WebView by their modified UA string. Other apps do not seem to be affected (e.g Twitter).
The default UIWebView UA is the same as Mobile Safari except the word Safari, which would still match.
The problem is that developers are free to change the user-agent to whatever they want, like Facebook has done. The jQuery browser UA regex depends on the webkit version number after AppleWebKit, if it doesn't find that, it goes through the possibilities, until it stops at mozilla. Of course the regex could be split up to first try to match the webkit and then the version number, but this is not sustainable, since that is only true on the Facebook app, other apps might change the user-agent differently. The only real fix, and what people should do anyway, is to not use user-agent and instead use feature testing.