mirror of
https://github.com/stablyai/orca.git
synced 2026-10-24 16:03:45 +00:00
fix(window): reject non-document navigation schemes
This commit is contained in:
@@ -55,13 +55,16 @@ describe('privileged window navigation policy', () => {
|
||||
expect(openExternal).toHaveBeenCalledWith('https://example.com/')
|
||||
})
|
||||
|
||||
it('lets the dev renderer origin navigate but not a foreign origin', () => {
|
||||
it('lets the dev renderer origin navigate but blocks foreign documents', () => {
|
||||
const fixture = createFixture('http://localhost:5173/')
|
||||
|
||||
expect(
|
||||
fixture.willNavigate('http://localhost:5173/index.html').preventDefault
|
||||
).not.toHaveBeenCalled()
|
||||
expect(fixture.willNavigate('https://example.com/').preventDefault).toHaveBeenCalled()
|
||||
expect(
|
||||
fixture.willNavigate('blob:http://localhost:5173/attacker-document').preventDefault
|
||||
).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
// Why: the packaged file: path is the whole privilege boundary, so a foreign host or a
|
||||
|
||||
@@ -19,6 +19,7 @@ export function isRendererDocumentNavigation(currentUrl: string, nextUrl: string
|
||||
}
|
||||
return (
|
||||
(current.protocol === 'http:' || current.protocol === 'https:') &&
|
||||
(next.protocol === 'http:' || next.protocol === 'https:') &&
|
||||
next.origin === current.origin
|
||||
)
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user