Bug Tracker

Ticket #11229 (closed bug: wontfix)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by sindresorhus

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.

Version 0, edited 3 years ago by sindresorhus (next)

comment:2 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to wontfix

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.

 http://api.jquery.com/category/deprecated/

comment:3 Changed 3 years ago by salomvary

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).

Note: See TracTickets for help on using tickets.