Editables: when formatting input value, make sure < and > stay < and >

This commit is contained in:
rolux 2014-02-04 06:46:28 +00:00
parent 64a92791ac
commit 0940d7317b
2 changed files with 8 additions and 4 deletions

View file

@ -192,6 +192,8 @@ Ox.Editable = function(options, self) {
self.options.type == 'input' self.options.type == 'input'
? self.options.value ? self.options.value
: self.options.value.replace(/<br\/?><br\/?>/g, '\n\n') : self.options.value.replace(/<br\/?><br\/?>/g, '\n\n')
.replace(/&lt;/g, '&amp;lt;')
.replace(/&gt;/g, '&amp;gt;')
); );
} }

View file

@ -87,9 +87,9 @@ Ox.EditableContent = function(options, self) {
}); });
}, },
paste: function(e) { paste: function(e) {
Ox.print('PASTE', e); //Ox.print('PASTE', e);
if (e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData) { if (e.originalEvent.clipboardData && e.originalEvent.clipboardData.getData) {
Ox.print('TYPES', e.originalEvent.clipboardData.types); //Ox.print('TYPES', e.originalEvent.clipboardData.types);
var value = e.originalEvent.clipboardData.getData('text/plain'); var value = e.originalEvent.clipboardData.getData('text/plain');
value = Ox.encodeHTMLEntities(value).replace(/\n\n\n/g, '<br/><br/>\n'); value = Ox.encodeHTMLEntities(value).replace(/\n\n\n/g, '<br/><br/>\n');
document.execCommand('insertHTML', false, value); document.execCommand('insertHTML', false, value);
@ -163,6 +163,8 @@ Ox.EditableContent = function(options, self) {
self.options.type == 'input' self.options.type == 'input'
? self.options.value ? self.options.value
: self.options.value.replace(/<br\/?><br\/?>/g, '\n\n') : self.options.value.replace(/<br\/?><br\/?>/g, '\n\n')
.replace(/&lt;/g, '&amp;lt;')
.replace(/&gt;/g, '&amp;gt;')
); );
} }