JangoSteve / remotipart

Rails jQuery file uploads via standard Rails "remote: true" forms.
http://os.alfajango.com/remotipart
Other
1k stars 215 forks source link

Fix issue #61. #114

Closed esbanarango closed 9 years ago

esbanarango commented 10 years ago

This PR fixes the issue when submitting via remotipart doesn't work with subdomains. The exact problem was:

Uncaught SecurityError: Blocked a frame with origin "http://subdomain.lvh.me:3000" from accessing a frame with origin "http://subdomain.lvh.me:3000". 
The frame requesting access set "document.domain" to "newinbox.lvh.me", but the frame being accessed did not. Both must set "document.domain" to the same value to allow access.

The solution is mentioned on MDN (Mozilla Developer Network).

solution

Why a "Try/Catch"?

That solution actually solves the subdomain issue, but it breaks when there is no subdomain, so we need to set document.domain=document.domain only when the iframe doesn't have access to the parent and vice versa (equals to having a subdomain).

esbanarango commented 9 years ago

@JangoSteve Any chance to check this? Thanks.

esbanarango commented 9 years ago

@JangoSteve I have seen a lot of new issues on this project and some new PR. I think this project is awesome and very useful. I offer myself to maintain this if you're maybe now too busy.

JangoSteve commented 9 years ago

@esbanarango Thanks for the offer. I just emailed you and went over some things like testing the project and whatnot for new features. If it's possible to read through that and through the "Tests" section of the Readme for this project, it'd be great if we could come up with a test case for this fix.

phlegx commented 9 years ago

:+1:

kuldeepaggarwal commented 9 years ago

@JangoSteve any updates on merging the existing PRs?

esbanarango commented 9 years ago

@kuldeepaggarwal hopefully it will be next week! Test suit needs to be set up properly before merging this.