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
           }
66
           }
67
           this.setTitlePlaceholder(this.props.titlePlaceholder);
67
           this.setTitlePlaceholder(this.props.titlePlaceholder);
68
           this.setContentPlaceholder(this.props.contentPlaceholder);
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
           this.props.editorInitializedCallback && this.props.editorInitializedCallback();
71
           this.props.editorInitializedCallback && this.props.editorInitializedCallback();
72
 
72
 
73
           break;
73
           break;
196
       .replace(/[\t]/g, '\\t');
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
   _sendAction(action, data) {
205
   _sendAction(action, data) {
200
     let jsonString = JSON.stringify({type: action, data});
206
     let jsonString = JSON.stringify({type: action, data});
201
     jsonString = this.escapeJSONString(jsonString);
207
     jsonString = this.escapeJSONString(jsonString);
310
   }
316
   }
311
 
317
 
312
   insertLink(url, title) {
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
   insertImage(url, alt) {
322
   insertImage(url, alt) {