javascript - TinyMCE Sanitizing input -


i'm trying use tinymce (version 4.1.2) wysiwyg editor. logged in users can write own pages , see directly shown on page when visitor visits.

now, i'd html stored directly. example:

the logged in user sees this text!, in fact tinymce displays <p>this text!</p>. there's styles <h1> , links can added.

now, user can insert hyperlink, giving link , text should displayed. problem however, if user manually write <a href='example.com'>example</a>, shows in editor gets stored in pure html well, when displaying hyperlink text example.

this how code sort of looks (left out configuration):

tinymce.init({     setup: function(editor){         editor.on('change', function(e){             $('[name="'+editor.id+'"]').next("textarea").html(editor.getcontent({format: 'html'}));         });     } }); 

so text tinymce field gets copied <textarea> inside <form> gets submitted when saving.

something this:

tinymce input of user

gets stored as:

<h1>title</h1> <p><a href="example.com">example</a></p> <p><a href="example.com">test</a></p> 

which leaves me no way distinguish genuine links , pure text, can't process after storing of data.

i've fiddled around editor.getcontent({format: 'html'}) format options, format: 'raw', no avail. doing wrong?

hopefully i'm understanding question correctly.

it looks you're wanting display whatever user inputs input without processing whatever html user wrote in html. correct? believe addresses issue you're having:

https://kokoblog.net/php/fix-tinymce-auto-convert-html-code-to-element-tag

however, if you're concerned how looks it's stored, , not how looks when it's processes you'll want add code blocks tinymce , make sure users understand need select code option whenever they're going write raw html.

    style_formats : [{title : 'code', inline : 'code'}] 

src: add "code" button wordpress tinymce

i hope helps! :)


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -