Closed Bug 1118404 Opened 9 years ago Closed 9 years ago

Make sure we do not auto-redirect/open iTunes Store links

Categories

(Firefox for iOS :: Browser, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
fxios + ---

People

(Reporter: st3fan, Assigned: st3fan)

Details

Attachments

(1 file)

Apple recently fixed a bug in Safari where pages could force the App Store app to open. This was usually done after clicking on an advertisement in a page but some apps also auto redirected to the app store app.

Safari changed this behavior by asking the user for confirmation first. We should clone that behavior when we work on the bug that handles the http://phobos.apple.com (iTunes store) style links.

Note that this should not just be done when the user requests navigation. We should also be sure that no JS can trigger a redirect without the users consent.
Do we have a bug to remove the confirmation on request by the user? I stumbled upon this trying out the 'Download on the App Store' button https://instagram.com/accounts/login/
We redirect without prompt

e.g snippet, 

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script>
        $(document).ready(function (){
         if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){
             window.location.href = 'https://itunes.apple.com/ca/app/twitter/id333903271?mt=8';
         }
        });
</script>
tracking-fxios: --- → ?
(Session restore on a page exemplifying similar code can also be a nuisance as it redirects away from the browser)
Assignee: nobody → sarentz
Status: NEW → ASSIGNED
This patch removes `itunes.apple.com` from a list of whitelisted URLs that are always allowed to open without user interaction. I am not sure why we had just `itunes.apple.com` in that whitelist because the result is that apps can auto redirect to the App Store.

I think the whole *open external app* code needs a revisit. The code looks flawed. It will also need a rewrite for iOS 9, where things work in a different way. But for now just removing this whitelist seems to do the trick: both when you click an app store link and when an app tries to auto-redirect to it, the user will get a confirmation prompt.

You can test the auto redirect on people.mozilla.com/~sarentz/t/itunes.html which opens an app store link upon loading.
Attachment #8649404 - Flags: review?(sleroux)
Attachment #8649404 - Flags: review?(bnicholson)
Attachment #8649404 - Flags: feedback?(aaron.train)
Note that we have a different bug where we show a 'Frame Load Interrupted' error when we give the user choice to open the external app. This is an error in the error pages code that does not take into account that loads can be interrupted this way. We should not show that error at all and just stay on the original page. Will file followup.
Comment on attachment 8649404 [details] [review]
PR: https://github.com/mozilla/firefox-ios/pull/949

NEW UPDATED PATCH

This patch adds a check to the logic that decided whether to show a confirmation dialog when the user opens a link that triggers an external app. Previously we would simply let all `itunes.apple.com` links open. With this extra check we explicitly ask the user for permission if the load was triggered by JavaScript or by a Reload. This prevents sites from sneaky opening app store links without user approval.

I think the whole *open external app* code needs a revisit. The code looks flawed and incomplete. It will also need a rewrite for iOS 9, where things work in a different way. I have tried to do this with minimal changes to prevent other regressions.

You can test the auto redirect on people.mozilla.com/~sarentz/t/itunes.html which opens an app store link upon loading.

On twitter.com there is a Install button that shows how it works for actual clicks. You need to be logged in to Twitter to see this.
Comment on attachment 8649404 [details] [review]
PR: https://github.com/mozilla/firefox-ios/pull/949

Good, clean fix. Works great!
Attachment #8649404 - Flags: review?(sleroux) → review+
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Attachment #8649404 - Flags: review?(bnicholson)
Attachment #8649404 - Flags: feedback?(aaron.train)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: