Skip to content

Commit 9294e74

Browse files
committed
Fix DOMPurify usage. To include this dependency in skillmap, I created a new pxtrcdeps (pxt react common dependencies) min.js file which includes (for now) just the DOMPurify code. Then I added a reference to it in skillmap.
1 parent 5cfcf9b commit 9294e74

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

cli/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,6 +2170,7 @@ function buildReactAppAsync(app: string, parsed: commandParser.ParsedCommand, op
21702170

21712171
nodeutil.cp("targetconfig.json", `${appRoot}/public/blb`);
21722172
nodeutil.cp("node_modules/pxt-core/built/pxtlib.js", `${appRoot}/public/blb`);
2173+
nodeutil.cp("node_modules/pxt-core/built/web/pxtrcdeps.js", `${appRoot}/public/blb`);
21732174
if (opts.includePxtSim) {
21742175
nodeutil.cp("node_modules/pxt-core/built/pxtsim.js", `${appRoot}/public/blb`);
21752176
nodeutil.cp("node_modules/pxt-core/built/web/worker.js", `${appRoot}/public/blb`);

gulpfile.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ const buildpxtjs = () => gulp.src([
102102
`))
103103
.pipe(gulp.dest("built"));
104104

105+
const pxtrcdeps = () => gulp.src([
106+
"node_modules/dompurify/dist/purify.min.js",
107+
])
108+
.pipe(concat("pxtrcdeps.js"))
109+
.pipe(gulp.dest("built/web"));
110+
111+
105112
const copySubappsConfig = () => gulp.src("cli/webapps-config.json")
106113
.pipe(gulp.dest("built"));
107114

@@ -122,7 +129,7 @@ function initWatch() {
122129
gulp.parallel(pxtblocks, pxteditor, pxtservices),
123130
gulp.parallel(pxtrunner, cli, pxtcommon),
124131
gulp.parallel(updatestrings, browserifyEmbed),
125-
gulp.parallel(pxtjs, pxtdts, pxtapp, pxtworker, pxtembed),
132+
gulp.parallel(pxtjs, pxtdts, pxtapp, pxtworker, pxtembed, pxtrcdeps),
126133
targetjs,
127134
reactCommon,
128135
webapp,
@@ -547,7 +554,7 @@ function createWebappTasks(root, outname) {
547554
.pipe(concat(`${outname}.html`))
548555
.pipe(gulp.dest("webapp/public")));
549556

550-
const result = gulp.series(cleanWebapp, buildWebapp, gulp.series(copyWebappCss, copyWebappJs, copyWebappHtml));
557+
const result = gulp.series(cleanWebapp, pxtrcdeps, buildWebapp, gulp.series(copyWebappCss, copyWebappJs, copyWebappHtml));
551558

552559
exports[outname] = result;
553560

@@ -748,7 +755,7 @@ const buildAll = gulp.series(
748755
gulp.parallel(pxteditor, pxtblocks, pxtservices),
749756
gulp.parallel(pxtrunner, cli, pxtcommon),
750757
browserifyEmbed,
751-
gulp.parallel(pxtjs, pxtdts, pxtapp, pxtworker, pxtembed),
758+
gulp.parallel(pxtjs, pxtdts, pxtapp, pxtworker, pxtembed, pxtrcdeps),
752759
targetjs,
753760
reactCommon,
754761
gulp.parallel(buildcss, buildSVGIcons),

react-common/components/theming/themeManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ export function getFullColorThemeCss(theme: pxt.ColorThemeInfo) {
108108
}
109109

110110
// Sanitize the CSS
111-
// TODO thsparks - get this working in skillmap somehow...
112-
// css = DOMPurify.sanitize(css);
111+
css = DOMPurify.sanitize(css);
113112

114113
return css;
115114
}

skillmap/public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<!-- target.js is generated by the CLI -->
1818
<script type="text/javascript" src="/blb/target.js"></script>
1919
<script type="text/javascript" src="/blb/pxtlib.js"></script>
20+
<script type="text/javascript" src="/blb/pxtrcdeps.js"></script>
2021

2122
<div id="root"></div>
2223

0 commit comments

Comments
 (0)