Skip to content
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

[Bug]: ERR_UNSAFE_REDIRECT #35581

Closed
3 tasks done
alhafram opened this issue Sep 6, 2022 · 4 comments
Closed
3 tasks done

[Bug]: ERR_UNSAFE_REDIRECT #35581

alhafram opened this issue Sep 6, 2022 · 4 comments
Labels
20-x-y bug/regression ↩️ A new version of Electron broke something has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/macOS

Comments

@alhafram
Copy link

alhafram commented Sep 6, 2022

Preflight Checklist

Electron Version

20.1.1

What operating system are you using?

macOS

Operating System Version

Ventura 13.0 Beta

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

20.0.3

Expected Behavior

No error when redirection happens in onBeforeRequest

Actual Behavior

Error when redirection happens in onBeforeRequest

Testcase Gist URL

No response

Additional Information

I redirect some remote scripts like in code below to some local and get this error

session.defaultSession.webRequest.onBeforeRequest(filter, (details, callback) => {
    if(details.resourceType == 'script') {
        if(details.url.includes('js/common.js?ux=')) {
            callback({
                redirectURL: `file://${app.getAppPath()}/src/Scripts/common.js`
            })
            return
        }
    }
})


Browser view setup code

const browserView = new BrowserView({
    webPreferences: {
        enablePreferredSizeMode: true,
        preload: path.join(__dirname, 'MainBrowserViewPreload.js'),
        contextIsolation: false,
        webSecurity: false,
        nodeIntegration: true,
        allowRunningInsecureContent: true,
        sandbox: false
    }
})
@codebytere
Copy link
Member

Thanks for reporting this and helping to make Electron better!

Because of time constraints, triaging code with third-party dependencies is usually not feasible for a small team like Electron's.

Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.

Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.

I'm adding the blocked/need-repro label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.

@codebytere codebytere added blocked/need-repro Needs a test case to reproduce the bug platform/macOS 20-x-y labels Sep 7, 2022
@alhafram
Copy link
Author

alhafram commented Sep 7, 2022

@vicrep
Copy link

vicrep commented Sep 12, 2022

I have a similar issue when upgrading from electron 19.0.11 to 19.0.14 (and when upgrading to latest v20). Looking at related changes, I have a feeling that this is what could've caused the issue: #35271

Still haven't found resolution steps though and not too sure if it's an intended error.

@ckerr ckerr added has-repro-gist Issue can be reproduced with code at https://gist.github.com/ bug/regression ↩️ A new version of Electron broke something and removed blocked/need-repro Needs a test case to reproduce the bug bug 🪲 labels Sep 12, 2022
@MarshallOfSound
Copy link
Member

Per #35357 this change is intentional, please read through that PR for how to change your code to not violate web security protections 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
20-x-y bug/regression ↩️ A new version of Electron broke something has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/macOS
Projects
None yet
Development

No branches or pull requests

5 participants