@wiris/mathtype-ckeditor5 7.29.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/plugin.js +15 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wiris/mathtype-ckeditor5",
3
- "version": "7.29.0",
3
+ "version": "8.0.0",
4
4
  "description": "MathType Web for CKEditor5 editor",
5
5
  "keywords": [
6
6
  "chem",
@@ -32,13 +32,13 @@
32
32
  ],
33
33
  "main": "src/plugin.js",
34
34
  "scripts": {
35
- "compile": "node ../../scripts/services/compile src/plugin.js ."
35
+ "build": "exit 0"
36
36
  },
37
37
  "dependencies": {
38
38
  "@ckeditor/ckeditor5-core": ">=23.0.0",
39
39
  "@ckeditor/ckeditor5-engine": ">=23.0.0",
40
40
  "@ckeditor/ckeditor5-ui": ">=23.0.0",
41
41
  "@ckeditor/ckeditor5-widget": ">=23.0.0",
42
- "@wiris/mathtype-html-integration-devkit": "1.8.0"
42
+ "@wiris/mathtype-html-integration-devkit": "1.9.0"
43
43
  }
44
44
  }
package/src/plugin.js CHANGED
@@ -256,13 +256,17 @@ export default class MathType extends Plugin {
256
256
  // And obtain the complete formula
257
257
  formula = `<math${mathAttributes}>${formula}</math>`;
258
258
 
259
+ // Skip if mathml contains a XSS injection
260
+ if (Util.containsXSS(formula)) {
261
+ return;
262
+ }
263
+
259
264
  /* Model node that contains what's going to actually be inserted. This can be either:
260
265
  - A <mathml> element with a formula attribute set to the given formula, or
261
266
  - If the original <math> had a LaTeX annotation, then the annotation surrounded by "$$...$$" */
262
267
  const modelNode = isLatex
263
268
  ? writer.createText(Parser.initParse(formula, editor.config.get('language')))
264
269
  : writer.createElement('mathml', { formula });
265
- modelNode.data = formula;
266
270
 
267
271
  // Find allowed parent for element that we are going to insert.
268
272
  // If current parent does not allow to insert element but one of the ancestors does
@@ -325,7 +329,9 @@ export default class MathType extends Plugin {
325
329
 
326
330
  const mathUIElement = createViewImage(modelItem, { writer: viewWriter }); // eslint-disable-line no-use-before-define
327
331
 
328
- viewWriter.insert(viewWriter.createPositionAt(widgetElement, 0), mathUIElement);
332
+ if (mathUIElement) {
333
+ viewWriter.insert(viewWriter.createPositionAt(widgetElement, 0), mathUIElement);
334
+ }
329
335
 
330
336
  return toWidget(widgetElement, viewWriter);
331
337
  }
@@ -340,9 +346,13 @@ export default class MathType extends Plugin {
340
346
  /* Although we use the HtmlDataProcessor to obtain the attributes,
341
347
  we must create a new EmptyElement which is independent of the
342
348
  DataProcessor being used by this editor instance */
343
- return viewWriter.createEmptyElement('img', imgElement.getAttributes(), {
344
- renderUnsafeAttributes: ['src'],
345
- });
349
+ if (imgElement) {
350
+ return viewWriter.createEmptyElement('img', imgElement.getAttributes(), {
351
+ renderUnsafeAttributes: ['src'],
352
+ });
353
+ }
354
+
355
+ return null;
346
356
  }
347
357
 
348
358
  // Model -> Editing view