Skip to content

Commit 205775a

Browse files
committed
Only serve HTML on specific index.html requests
Otherwise there is risk of an infinite loop through the iframe where the fallback keeps loading the root HTML which itself has an iframe...
1 parent 4cc181c commit 205775a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/node/app/server.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as http from "http"
33
import * as React from "react"
44
import * as ReactDOMServer from "react-dom/server"
55
import App from "../../browser/app"
6+
import { HttpCode, HttpError } from "../../common/http"
67
import { Options } from "../../common/util"
78
import { HttpProvider, HttpResponse, Route } from "../http"
89

@@ -21,6 +22,9 @@ export class MainHttpProvider extends HttpProvider {
2122
}
2223

2324
case "/": {
25+
if (route.requestPath !== "/index.html") {
26+
throw new HttpError("Not found", HttpCode.NotFound)
27+
}
2428
const options: Options = {
2529
authed: !!this.authenticated(request),
2630
basePath: this.base(route),

src/node/vscode/server.ts

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
VscodeOptions,
1212
WorkbenchOptions,
1313
} from "../../../lib/vscode/src/vs/server/ipc"
14+
import { HttpCode, HttpError } from "../../common/http"
1415
import { generateUuid } from "../../common/util"
1516
import { HttpProvider, HttpProviderOptions, HttpResponse, Route } from "../http"
1617
import { SettingsProvider } from "../settings"
@@ -114,6 +115,9 @@ export class VscodeHttpProvider extends HttpProvider {
114115
this.ensureAuthenticated(request)
115116
switch (route.base) {
116117
case "/":
118+
if (route.requestPath !== "/index.html") {
119+
throw new HttpError("Not found", HttpCode.NotFound)
120+
}
117121
try {
118122
return await this.getRoot(request, route)
119123
} catch (error) {

0 commit comments

Comments
 (0)