@evolvere/sgp-ui 1.6.9 → 1.6.10

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 (97) hide show
  1. package/lib/alert.js +2 -2
  2. package/lib/aside.js +2 -2
  3. package/lib/autocomplete.js +4 -4
  4. package/lib/avatar.js +2 -2
  5. package/lib/backtop.js +4 -4
  6. package/lib/badge.js +2 -2
  7. package/lib/breadcrumb-item.js +2 -2
  8. package/lib/breadcrumb.js +2 -2
  9. package/lib/button-group.js +2 -2
  10. package/lib/button.js +2 -2
  11. package/lib/calendar.js +6 -6
  12. package/lib/card.js +2 -2
  13. package/lib/carousel-item.js +2 -2
  14. package/lib/carousel.js +4 -4
  15. package/lib/cascader-panel.js +12 -12
  16. package/lib/cascader.js +13 -13
  17. package/lib/checkbox-button.js +9 -9
  18. package/lib/checkbox-group.js +9 -9
  19. package/lib/checkbox.js +2 -2
  20. package/lib/col.js +2 -2
  21. package/lib/collapse-item.js +7 -7
  22. package/lib/collapse.js +2 -2
  23. package/lib/color-picker.js +2 -2
  24. package/lib/container.js +2 -2
  25. package/lib/date-picker.js +10 -10
  26. package/lib/descriptions-item.js +2 -2
  27. package/lib/descriptions.js +2 -2
  28. package/lib/dialog.js +2 -2
  29. package/lib/divider.js +2 -2
  30. package/lib/drawer.js +2 -2
  31. package/lib/dropdown-item.js +2 -2
  32. package/lib/dropdown-menu.js +2 -2
  33. package/lib/dropdown.js +4 -4
  34. package/lib/editor.js +258 -32
  35. package/lib/empty.js +2 -2
  36. package/lib/footer.js +2 -2
  37. package/lib/form-item.js +4 -4
  38. package/lib/form.js +2 -2
  39. package/lib/header.js +2 -2
  40. package/lib/icon.js +2 -2
  41. package/lib/image.js +4 -4
  42. package/lib/index.js +1 -1
  43. package/lib/infinite-scroll.js +2 -2
  44. package/lib/input-number.js +6 -6
  45. package/lib/input.js +4 -4
  46. package/lib/link.js +2 -2
  47. package/lib/loading.js +4 -4
  48. package/lib/main.js +2 -2
  49. package/lib/menu-item-group.js +2 -2
  50. package/lib/menu-item.js +6 -6
  51. package/lib/menu.js +2 -2
  52. package/lib/message-box.js +6 -6
  53. package/lib/message.js +4 -4
  54. package/lib/notification.js +4 -4
  55. package/lib/option-group.js +2 -2
  56. package/lib/option.js +4 -4
  57. package/lib/page-header.js +2 -2
  58. package/lib/pagination.js +6 -6
  59. package/lib/popconfirm.js +4 -4
  60. package/lib/popover.js +2 -2
  61. package/lib/progress.js +2 -2
  62. package/lib/radio-button.js +2 -2
  63. package/lib/radio-group.js +2 -2
  64. package/lib/radio.js +2 -2
  65. package/lib/rate.js +2 -2
  66. package/lib/rdc-sgp-ui.common.js +321 -97
  67. package/lib/result.js +2 -2
  68. package/lib/row.js +2 -2
  69. package/lib/scrollbar.js +4 -4
  70. package/lib/select.js +15 -15
  71. package/lib/skeleton-item.js +2 -2
  72. package/lib/skeleton.js +2 -2
  73. package/lib/slider.js +6 -6
  74. package/lib/spinner.js +2 -2
  75. package/lib/step.js +2 -2
  76. package/lib/steps.js +2 -2
  77. package/lib/submenu.js +6 -6
  78. package/lib/switch.js +4 -4
  79. package/lib/tab-pane.js +2 -2
  80. package/lib/table-column.js +2 -2
  81. package/lib/table.js +19 -17
  82. package/lib/tabs.js +2 -2
  83. package/lib/tag.js +2 -2
  84. package/lib/time-picker.js +11 -11
  85. package/lib/time-select.js +6 -6
  86. package/lib/timeline-item.js +2 -2
  87. package/lib/timeline.js +2 -2
  88. package/lib/tooltip.js +2 -2
  89. package/lib/transfer.js +4 -4
  90. package/lib/tree.js +7 -7
  91. package/lib/upload.js +10 -10
  92. package/package.json +3 -1
  93. package/packages/editor/src/html-security.js +180 -0
  94. package/packages/editor/src/index.vue +68 -15
  95. package/packages/editor/src/video-security.js +1 -0
  96. package/packages/theme-chalk/package.json +1 -1
  97. package/src/index.js +1 -1
@@ -3,15 +3,23 @@
3
3
  </template>
4
4
 
5
5
  <script>
6
+ import {
7
+ MAX_IMAGE_COUNT,
8
+ MAX_IMAGE_SIZE,
9
+ isSafeLink,
10
+ isSafeMediaSource,
11
+ sanitizeEditorHtml,
12
+ validateImageFiles
13
+ } from './html-security';
6
14
  import { validateOnlineVideo } from './video-security';
7
15
 
8
- let signIsEditorChange = true;
9
16
  export default {
10
17
  name: 'ElEditor',
11
18
  data() {
12
19
  return {
13
20
  editor: null,
14
- editorData: ''
21
+ editorData: '',
22
+ isEditorChange: true
15
23
  };
16
24
  },
17
25
  props: {
@@ -69,7 +77,8 @@ export default {
69
77
  editor.config.uploadImgServer = '/apiv2/nfs/file/upload/wangEditor';
70
78
  }
71
79
  editor.config.showLinkImg = false;
72
- editor.config.uploadImgMaxSize = 1000 * 1024 * 1024; // 100M
80
+ editor.config.uploadImgMaxSize = MAX_IMAGE_SIZE;
81
+ editor.config.uploadImgMaxLength = MAX_IMAGE_COUNT;
73
82
  editor.config.emotions = [
74
83
  {
75
84
  title: 'emoji',
@@ -83,6 +92,46 @@ export default {
83
92
  ...this.options
84
93
  };
85
94
 
95
+ const customPasteTextHandle = editor.config.pasteTextHandle;
96
+ const customLinkCheck = editor.config.linkCheck;
97
+ const customLinkImgCheck = editor.config.linkImgCheck;
98
+ const customUploadImgBefore = editor.config.uploadImgHooks && editor.config.uploadImgHooks.before;
99
+
100
+ // Security-sensitive settings cannot be relaxed through component options.
101
+ editor.config.uploadImgServer = '/apiv2/nfs/file/upload/wangEditor';
102
+ editor.config.uploadImgShowBase64 = false;
103
+ editor.config.showLinkImg = false;
104
+ editor.config.uploadImgAccept = ['jpg', 'jpeg', 'png', 'gif'];
105
+ editor.config.uploadImgMaxSize = MAX_IMAGE_SIZE;
106
+ editor.config.uploadImgMaxLength = MAX_IMAGE_COUNT;
107
+ editor.config.withCredentials = true;
108
+ editor.config.pasteTextHandle = content => sanitizeEditorHtml(
109
+ typeof customPasteTextHandle === 'function' ? customPasteTextHandle(content) : content
110
+ );
111
+ editor.config.linkCheck = (text, link) => {
112
+ if (!isSafeLink(link)) return '链接地址不安全,仅支持 http、https、mailto 和 tel';
113
+ return typeof customLinkCheck === 'function' ? customLinkCheck(text, link) : true;
114
+ };
115
+ editor.config.linkImgCheck = (src, alt, href) => {
116
+ if (!isSafeMediaSource(src) || (href && !isSafeLink(href))) {
117
+ return '图片地址不安全';
118
+ }
119
+ return typeof customLinkImgCheck === 'function'
120
+ ? customLinkImgCheck(src, alt, href)
121
+ : true;
122
+ };
123
+ editor.config.uploadImgHooks = {
124
+ ...editor.config.uploadImgHooks,
125
+ before: (xhr, currentEditor, files) => {
126
+ if (!validateImageFiles(files)) {
127
+ return {prevent: true, msg: '仅允许上传 10 张以内、单张不超过 5MB 的 JPG、PNG 或 GIF 图片'};
128
+ }
129
+ return typeof customUploadImgBefore === 'function'
130
+ ? customUploadImgBefore(xhr, currentEditor, files)
131
+ : undefined;
132
+ }
133
+ };
134
+
86
135
  // wangEditor 4 inserts online-video markup with insertHTML. Always run the
87
136
  // built-in security check before an optional consumer-provided validator.
88
137
  const customOnlineVideoCheck = editor.config.onlineVideoCheck;
@@ -95,29 +144,27 @@ export default {
95
144
  };
96
145
 
97
146
  editor.config.onchange = newHtml => {
98
- // this.editorData = newHtml;
99
- signIsEditorChange = false;
100
- this.$emit('input', newHtml);
147
+ const safeHtml = sanitizeEditorHtml(newHtml);
148
+ this.isEditorChange = false;
149
+ this.$emit('input', safeHtml);
101
150
  this.$nextTick(() => {
102
- signIsEditorChange = true;
151
+ this.isEditorChange = true;
103
152
  });
104
- this.$emit('change', {html: newHtml, text: editor.txt.text(), editor});
153
+ this.$emit('change', {html: safeHtml, text: editor.txt.text(), editor});
105
154
  };
106
155
 
107
156
  editor.config.onblur = newHtml => {
108
- // this.editorData = newHtml;
109
- this.$emit('blur', {html: newHtml, text: editor.txt.text(), editor});
157
+ this.$emit('blur', {html: sanitizeEditorHtml(newHtml), text: editor.txt.text(), editor});
110
158
  };
111
159
 
112
160
  editor.config.onfocus = newHtml => {
113
- // this.editorData = newHtml;
114
- this.$emit('focus', {html: newHtml, text: editor.txt.text(), editor});
161
+ this.$emit('focus', {html: sanitizeEditorHtml(newHtml), text: editor.txt.text(), editor});
115
162
  };
116
163
 
117
164
  editor.create();
118
165
 
119
166
  const initValue = (this.value !== undefined && this.value !== null) ? this.value : this.content;
120
- editor.txt.html(initValue);
167
+ editor.txt.html(sanitizeEditorHtml(initValue || ''));
121
168
  if (this.disabled) {
122
169
  editor.disable();
123
170
  }
@@ -135,10 +182,16 @@ export default {
135
182
  }
136
183
  },
137
184
  value() {
138
- if (this.editor && signIsEditorChange) {
139
- this.editor.txt.html(this.value);
185
+ if (this.editor && this.isEditorChange) {
186
+ this.editor.txt.html(sanitizeEditorHtml(this.value || ''));
140
187
  }
141
188
  }
189
+ },
190
+ beforeDestroy() {
191
+ if (this.editor) {
192
+ this.editor.destroy();
193
+ this.editor = null;
194
+ }
142
195
  }
143
196
  };
144
197
  </script>
@@ -6,6 +6,7 @@ const ALLOWED_IFRAME_ATTRIBUTES = [
6
6
  'loading',
7
7
  'mozallowfullscreen',
8
8
  'referrerpolicy',
9
+ 'sandbox',
9
10
  'src',
10
11
  'title',
11
12
  'webkitallowfullscreen',
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evolvere/element-theme-chalk",
3
- "version": "1.6.9",
3
+ "version": "1.6.10",
4
4
  "description": "Element component chalk theme.",
5
5
  "main": "lib/index.css",
6
6
  "style": "lib/index.css",
package/src/index.js CHANGED
@@ -212,7 +212,7 @@ if (typeof window !== 'undefined' && window.Vue) {
212
212
  }
213
213
 
214
214
  export default {
215
- version: '1.6.9',
215
+ version: '1.6.10',
216
216
  locale: locale.use,
217
217
  i18n: locale.i18n,
218
218
  install,