M and MSM Series
cancel
Showing results for 
Search instead for 
Did you mean: 

MSM765zl Max length of userAgent in javascript

 
Highlighted
Advisor

MSM765zl Max length of userAgent in javascript

OK, so in dealing with an iPhone/iPad login problem via the 765zl, I've had to recode the main login page. In the prototype.js file, there is a object that detects the userAgent (specifically Apple Safari in my case) with:

MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
>

Unfortunately, this doesn't match newer devices. What I've found is that the Apple device is sending the entire userAgent as expected, but if I print out the value of the userAgent with:
<script>
document.write("js userAgent: "+navigator.userAgent+" ::END");
</script>
(in index.asp), then the userAgent string is truncated right before the 'Safari' portion. The odd thing is that this isn't a character position or number of words, but rather some other limit.
For example the following userAgent is printed in full (from an iPod Touch with os 2.x):
Mozilla/5.0 (iPod; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5H11 Safari/525.20

The following (iPad, OS3) is truncated with the last portion displayed being "Mobile/7B367":
Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10

The last example is from an iPhone with developer version 4.0 on it, again, truncated right before 'Safari' (displaying 'Mobile/8A293'):
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7

I'm currently just checking for /Apple.*Mobile/ instead of the full /Apple.*Mobile.*Safari/ that is in prototype.js.

I know that many web servers have a limit of 260 characters in the userAgent string, but I'm _way_ under that (146 for the iOS 4.0 phone, 145 for the working iPod 2.0) and 141 for the failing iPad 3.0).
Anyone see this before and know of a way to see the full userAgent string???
Thanks!
Tom

 

P.S. This thread has been moved from Communications, Wireless (Legacy ITRC forum) to MSM Series. -HP Forum Moderator

1 REPLY 1
Highlighted
Advisor

Re: MSM765zl Max length of userAgent in javascript

Hmm, in thinking about this more, isn't this a client-side issue where the problem would be with the Apple mobile device truncating the length?
If that's so, then I should be able to write a quick webpage to display the navigator.userAgent.

Yep, I could and did, here's what I found:

Turns out that if the Controller/Public access/Web content/'Redirect users to the Login page via:' has 'HTTP' checked, then the newer mobile devices will bring up the login page after you select the SSID. It seems that the browser that is used to display the login page isn't the 'full' Safari browser which truncates the length of the navigator.userAgent. If HTTPS is checked instead of HTTP, then the login page isn't brought up during the SSID selection and isn't displayed until the full Safari browser is launched. Then, the full userAgent string is displayed in all it's glory.
Looks to be an Apple problem after all.
Sorry for bothering everyone...
Tom