Skip to content

Commit 737f820

Browse files
committed
fix issue #4322 and also an issue with bokeh
- this will probably randomly break some other things in surprising ways, unfortunately. However, it'll fix a lot of things too...
1 parent ca186f0 commit 737f820

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/packages/jupyter/blobs/iframe.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { decode } from "he";
1313
//import { getLogger } from "@cocalc/backend/logger";
1414
//const logger = getLogger("jupyter:blobs:iframe");
1515

16+
// see https://github.com/sagemathinc/cocalc/issues/4322
17+
const MAX_HTML_SIZE = 10 ** 6;
18+
1619
// We use iframes to render html in a number of cases:
1720
// - if it starts with iframe
1821
// - if it has a whole page doctype
@@ -26,6 +29,18 @@ export function is_likely_iframe(content: string): boolean {
2629
return false;
2730
}
2831
content = content.toLowerCase();
32+
if (
33+
content.includes("https://bokeh.org") &&
34+
content.includes("bk-notebook-logo")
35+
) {
36+
// Do NOT use an iframe for bokeh no matter what, since this won't work properly.
37+
// Hopefully the above heuristic is sufficiently robust to detect but not overdetect.
38+
return false;
39+
}
40+
if (content.length >= MAX_HTML_SIZE) {
41+
// it'll just break anyways if we don't use an iframe -- if we do, there is hope.
42+
return true;
43+
}
2944
return (
3045
content.includes("bk-notebook-logo") ||
3146
content.startsWith("<iframe") ||

0 commit comments

Comments
 (0)