Skip to content

Commit f5bbb11

Browse files
committed
migrate google-caja to npm and apply patch
1 parent 4ecb78e commit f5bbb11

File tree

6 files changed

+45
-85
lines changed

6 files changed

+45
-85
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"watch:css": "onchange 'nbclassic/static/**/*.less' -- npm run build:css",
3535
"watch:js": "onchange 'nbclassic/static/**/!(*.min).js' 'bower.json' -- npm run build:js",
3636
"watch": "npm-run-all --parallel watch:*",
37-
"postinstall": "node postinstall.js"
37+
"postinstall": "node postinstall.js && npx patch-package google-caja-sanitizer"
3838
},
3939
"devDependencies": {
4040
"@babel/core": "^7.15.0",
@@ -63,7 +63,7 @@
6363
"mathjax": "^2.7.4",
6464
"codemirror": "~5.58.2",
6565
"es6-promise": "~1.0",
66-
"@bower_components/google-caja": "https://github.com/minrk/google-caja-bower/archive/refs/tags/5669.0.0.tar.gz",
66+
"google-caja-sanitizer": "~1.0.4",
6767
"jed": "~1.1.1",
6868
"jquery": "~3.7.1",
6969
"jquery-typeahead": "~2.11.1",
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff --git a/node_modules/google-caja-sanitizer/sanitizer.js b/node_modules/google-caja-sanitizer/sanitizer.js
2+
index bf8ff98..43e8173 100644
3+
--- a/node_modules/google-caja-sanitizer/sanitizer.js
4+
+++ b/node_modules/google-caja-sanitizer/sanitizer.js
5+
@@ -4919,16 +4919,16 @@ var html = (function(html4) {
6+
})(html4);
7+
8+
9+
-exports.escapeAttrib = html.escapeAttrib;
10+
-exports.makeHtmlSanitizer = html.makeHtmlSanitizer;
11+
-exports.makeSaxParser = html.makeSaxParser;
12+
-exports.makeTagPolicy = html.makeTagPolicy;
13+
-exports.normalizeRCData = html.normalizeRCData;
14+
-exports.sanitize = html.sanitize;
15+
-exports.smartSanitize = function (string, urlX, idX) {
16+
- string = string.replace(/<([a-zA-Z]+)([^>]*)\/>/g, '<$1$2></$1>');
17+
- return html.sanitize(string, urlX, idX);
18+
-}
19+
-exports.sanitizeAttribs = html.sanitizeAttribs;
20+
-exports.sanitizeWithPolicy = html.sanitizeWithPolicy;
21+
-exports.unescapeEntities = html.unescapeEntities;
22+
+// exports.escapeAttrib = html.escapeAttrib;
23+
+// exports.makeHtmlSanitizer = html.makeHtmlSanitizer;
24+
+// exports.makeSaxParser = html.makeSaxParser;
25+
+// exports.makeTagPolicy = html.makeTagPolicy;
26+
+// exports.normalizeRCData = html.normalizeRCData;
27+
+// exports.sanitize = html.sanitize;
28+
+// exports.smartSanitize = function (string, urlX, idX) {
29+
+// string = string.replace(/<([a-zA-Z]+)([^>]*)\/>/g, '<$1$2></$1>');
30+
+// return html.sanitize(string, urlX, idX);
31+
+// }
32+
+// exports.sanitizeAttribs = html.sanitizeAttribs;
33+
+// exports.sanitizeWithPolicy = html.sanitizeWithPolicy;
34+
+// exports.unescapeEntities = html.unescapeEntities;

postinstall.js

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -39,87 +39,12 @@ function ensureSymlink(sourcePath, targetPath) {
3939
}
4040
}
4141

42-
// Symlink bower_components
43-
ensureSymlink("node_modules/@bower_components", "nbclassic/static/components");
44-
4542
// Symlink other static assets no longer in bower_components
4643
ensureSymlink(
47-
"node_modules/marked",
48-
"nbclassic/static/components/marked"
49-
);
50-
ensureSymlink(
51-
"node_modules/font-awesome",
52-
"nbclassic/static/components/font-awesome"
53-
);
54-
ensureSymlink(
55-
"node_modules/backbone",
56-
"nbclassic/static/components/backbone"
57-
);
58-
ensureSymlink(
59-
"node_modules/bootstrap",
60-
"nbclassic/static/components/bootstrap"
61-
);
62-
ensureSymlink(
63-
"node_modules/bootstrap-tour",
64-
"nbclassic/static/components/bootstrap-tour"
65-
);
66-
ensureSymlink(
67-
"node_modules/jed",
68-
"nbclassic/static/components/jed"
69-
);
70-
ensureSymlink(
71-
"node_modules/moment",
72-
"nbclassic/static/components/moment"
73-
);
74-
ensureSymlink(
75-
"node_modules/text-encoding",
76-
"nbclassic/static/components/text-encoding"
77-
);
78-
ensureSymlink(
79-
"node_modules/underscore",
80-
"nbclassic/static/components/underscore"
81-
);
82-
ensureSymlink(
83-
"node_modules/jquery",
84-
"nbclassic/static/components/jquery"
85-
);
86-
ensureSymlink(
87-
"node_modules/jquery-ui",
88-
"nbclassic/static/components/jquery-ui"
89-
);
90-
ensureSymlink(
91-
"node_modules/jquery-typeahead",
92-
"nbclassic/static/components/jquery-typeahead"
44+
"node_modules",
45+
"nbclassic/static/components"
9346
);
9447
ensureSymlink(
9548
"node_modules/mathjax",
9649
"nbclassic/static/components/MathJax"
9750
);
98-
ensureSymlink(
99-
"node_modules/codemirror",
100-
"nbclassic/static/components/codemirror"
101-
);
102-
ensureSymlink(
103-
"node_modules/react",
104-
"nbclassic/static/components/react"
105-
);
106-
ensureSymlink(
107-
"node_modules/react-dom",
108-
"nbclassic/static/components/react-dom"
109-
);
110-
ensureSymlink(
111-
"node_modules/es6-promise",
112-
"nbclassic/static/components/es6-promise"
113-
);
114-
ensureSymlink(
115-
"node_modules/requirejs",
116-
"nbclassic/static/components/requirejs"
117-
);
118-
ensureSymlink(
119-
"node_modules/requirejs-plugins",
120-
"nbclassic/static/components/requirejs-plugins"
121-
);
122-
ensureSymlink(
123-
"node_modules/requirejs-text",
124-
"nbclassic/static/components/requirejs-text"
125-
);

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ artifacts = [
129129
"nbclassic/static/components/bootstrap-tour/build/js/bootstrap-tour.min.js" = "nbclassic/static/components/bootstrap-tour/build/js/bootstrap-tour.min.js"
130130
"nbclassic/static/components/bootstrap/dist/js/bootstrap.min.js" = "nbclassic/static/components/bootstrap/dist/js/bootstrap.min.js"
131131
"nbclassic/static/components/create-react-class/index.js" = "nbclassic/static/components/create-react-class/index.js"
132-
"nbclassic/static/components/google-caja/html-css-sanitizer-minified.js" = "nbclassic/static/components/google-caja/html-css-sanitizer-minified.js"
132+
"nbclassic/static/components/google-caja-sanitizer/sanitizer.js" = "nbclassic/static/components/google-caja-sanitizer/sanitizer.js"
133133
"nbclassic/static/components/jed/jed.js" = "nbclassic/static/components/jed/jed.js"
134134
"nbclassic/static/components/jquery/dist/jquery.min.js" = "nbclassic/static/components/jquery/dist/jquery.min.js"
135135
"nbclassic/static/components/jquery-typeahead/dist/jquery.typeahead.min.js" = "nbclassic/static/components/jquery-typeahead/dist/jquery.typeahead.min.js"

tools/security_deprecated.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
define([
55
'jquery',
6-
'components/google-caja/html-css-sanitizer-minified',
6+
'components/google-caja-sanitizer/sanitizer',
77
], function($, sanitize) {
88
"use strict";
99

yarn.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,6 @@
841841
classnames "^2.2"
842842
tslib "~2.3.1"
843843

844-
"@bower_components/google-caja@https://github.com/minrk/google-caja-bower/archive/refs/tags/5669.0.0.tar.gz":
845-
version "0.0.0"
846-
resolved "https://github.com/minrk/google-caja-bower/archive/refs/tags/5669.0.0.tar.gz#6830582db17ef8087e38d3aa9703966fb9a86278"
847-
848844
"@discoveryjs/json-ext@^0.5.0":
849845
version "0.5.7"
850846
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
@@ -2077,6 +2073,11 @@ globals@^11.1.0:
20772073
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
20782074
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==
20792075

2076+
google-caja-sanitizer@~1.0.4:
2077+
version "1.0.4"
2078+
resolved "https://registry.yarnpkg.com/google-caja-sanitizer/-/google-caja-sanitizer-1.0.4.tgz#614cf2c3d2e5e83ea961ab98d79318c03d8682e5"
2079+
integrity sha512-KEqGmAIbxvEZy4nPLpVoAlxQhEoq4H/0WMEQsEXlxjP+OxCT9nDYQi7Z7PVanwb77Jc+OJ9SoBQ6zw2OnmCvLw==
2080+
20802081
gopd@^1.0.1, gopd@^1.2.0:
20812082
version "1.2.0"
20822083
resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1"

0 commit comments

Comments
 (0)