Ver código fonte

make sure html is encoded. for some reason, the apostrophe caused issues.

Artal Druk 8 anos atrás
pai
commit
803a814025
1 arquivos alterados com 9 adições e 4 exclusões
  1. 9
    4
      src/RichTextEditor.js

+ 9
- 4
src/RichTextEditor.js Ver arquivo

@@ -66,8 +66,8 @@ export default class RichTextEditor extends Component {
66 66
           }
67 67
           this.setTitlePlaceholder(this.props.titlePlaceholder);
68 68
           this.setContentPlaceholder(this.props.contentPlaceholder);
69
-          this.setTitleHTML(this.props.initialTitleHTML);
70
-          this.setContentHTML(this.props.initialContentHTML);
69
+          this.setTitleHTML(this.htmlEcodeString(this.props.initialTitleHTML));
70
+          this.setContentHTML(this.htmlEcodeString(this.props.initialContentHTML));
71 71
           this.props.editorInitializedCallback && this.props.editorInitializedCallback();
72 72
 
73 73
           break;
@@ -196,6 +196,12 @@ export default class RichTextEditor extends Component {
196 196
       .replace(/[\t]/g, '\\t');
197 197
   };
198 198
 
199
+  htmlEcodeString = function (string) {
200
+    //for some reason there's an issue only with apostrophes
201
+    return string
202
+      .replace(/'/g, ''');
203
+  }
204
+
199 205
   _sendAction(action, data) {
200 206
     let jsonString = JSON.stringify({type: action, data});
201 207
     jsonString = this.escapeJSONString(jsonString);
@@ -310,8 +316,7 @@ export default class RichTextEditor extends Component {
310 316
   }
311 317
 
312 318
   insertLink(url, title) {
313
-
314
-    this._sendAction(actions.insertLink, {url, title});
319
+    this._sendAction(actions.insertLink, {url, title: this.htmlEcodeString(title)});
315 320
   }
316 321
 
317 322
   insertImage(url, alt) {