Browse Source

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

Artal Druk 8 years ago
parent
commit
803a814025
1 changed files with 9 additions and 4 deletions
  1. 9
    4
      src/RichTextEditor.js

+ 9
- 4
src/RichTextEditor.js View File

@@ -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) {