You are not logged in.

#1 2007-12-31 12:11:18

Roberto.Roncato
Member
Registered: 2007-12-31
Posts: 6

Resolved .NET validating request for HTML tags

With the following config/code you can use tiny with .net
The most valued solution (ValidateRequest=false) is a dangerous way because this disable the .net integrated validation system

function myCustomCleanup(type, value)
{   if (type == "insert_to_editor")
     {   value = value.replace(/&lt;/gi,"<");
          value = value.replace(/&gt;/gi,">");
     }
     return value;
}
function myCustomSaveContent(element_id, html, body)
{   html= html.replace(/</gi,"&lt;");
     html= html.replace(/>/gi,"&gt;");
     return html;
}
tinyMCE.init({
          .... ,    
          cleanup_callback : "myCustomCleanup",
          save_callback : "myCustomSaveContent"
          });

Offline

 

#2 2008-05-23 11:59:58

deostroll
Member
Registered: 2008-05-23
Posts: 3

Re: Resolved .NET validating request for HTML tags

What if there were actually < or > signs in the content other than the html tags?

Offline

 

#3 2008-08-12 11:57:27

taliesins
Member
Registered: 2008-08-12
Posts: 4

Re: Resolved .NET validating request for HTML tags

I think this is the way to go!

Regards Tali


    _onEditorBeforeSetContentHandler : function(editor, object)
    {
        object.content = this._htmlDecode(object.content);
    },
   
    _onEditorPostProcessHandler : function(editor, object)
    {
        if (object.set)
            object.content = this._htmlDecode(object.content);

        if (object.get)
            object.content = this._htmlEncode(object.content);
    },
   
    _htmlEncode : function(content)
    {
        // Change html content to encoded content
        // Encoded html will keep ASP.Net validation happy
        content = content.replace(/&/gi, "&amp;").replace(/\""/gi, "&quot;").replace(/</gi, "&lt;").replace(/\>/gi, "&gt;");
        return content;
    },
   
    _htmlDecode : function(content)
    {
        //Change encoded content to valid html content
        content = content.replace(/&gt;/gi,">").replace(/&lt;/gi,"<").replace(/&quot;/gi, "\"").replace(/&amp;/gi, "&");
        return content;
    },

Offline

 

#4 2008-08-14 21:15:52

ESBertrand
Member
Registered: 2008-01-22
Posts: 5

Re: Resolved .NET validating request for HTML tags

taliesins:

Could you clarify where this code should go?  It looks like it should be appended to the list of parameters for the tinyMCE.init(...) call, but they do not seem to work in my .NET environment (I still get the "potentially dangerous..." error on postback).

Is there more code I need to add to "register" the _onEditorBeforeSetContentHandler and _onEditorPostProcessHandler event routines?

Erik

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB