Skip to content

web: Don't show CORS error message for the Internet Archive #20770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danielhjacobs
Copy link
Contributor

Not sure how I feel about this, on the one hand it's simple and helps to stop the issues saying "why does the Internet Archive have this CORS error", but on the other hand is a single hard-coded URL. It's tough to do things any other way because the Internet Archive lies about the URL it's actually fetching due to its custom fetch code that redirects all requests to itself.

@danielhjacobs danielhjacobs requested a review from Dinnerbone June 18, 2025 21:00
@danielhjacobs danielhjacobs added A-web Area: Web & Extensions T-fix Type: Bug fix (in something that's supposed to work already) labels Jun 18, 2025
@n0samu
Copy link
Member

n0samu commented Jun 18, 2025

I remember I had a different idea for how to accomplish this without hardcoding the URL - let me try to dig it up in the next few days

@danielhjacobs
Copy link
Contributor Author

One way I thought of just now would be:

window.location.origin === new URL((await fetch(error.swfUrl)).url).origin

On https://web.archive.org/web/20250119102449/https://www.dnai.org/, window.location.origin === new URL((await fetch("not_a_real.swf")).url).origin

Not sure I'd want to re-do a fetch just for this though.

@danielhjacobs
Copy link
Contributor Author

Working through the logic straight through the Rust code, I guess that is this:

https://github.com/ruffle-rs/ruffle/blob/master/core/src/tag_utils.rs#L58

I guess a more accurate swfUrl would be that.

@danielhjacobs
Copy link
Contributor Author

Last thought wasn't quite right, but it can be done by adding a new parameter for the real SWF URL that we attempt to fetch to this function:

fn display_root_movie_download_failed_message(&self, _invalid_swf: bool);

@danielhjacobs
Copy link
Contributor Author

Here, that's error.url:

.display_root_movie_download_failed_message(false);

Here, it's url:

.display_root_movie_download_failed_message(true);

Here, it's spoofed_or_swf_url:

.display_root_movie_download_failed_message(true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web Area: Web & Extensions T-fix Type: Bug fix (in something that's supposed to work already)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants