HTML encode/decode in textarea

Hello.

I have a problem that all my ev.text gets HTML encoded in my textarea in the form. The same ev.text does not get encoded when shown on the “event_bar_text”.

See attached picture. My textarea field has the description “Comments” in the image.

In the backend database there is no encoding stored.

Is there a way to html decode the ev.text? I have tried with an external js script like below without success:

[code]function textarea_decode(start, end, ev) {
return Encoder.htmlDecode(ev.text);
}

scheduler.templates.event_text = textarea_decode;[/code]


Most probably - issue caused by DataBase. If you are using connectors, and non-unicode database ( check collation of table and separate text fields ) - data will be escaped before inserting in the database. Which can result in above problem.

It possible to add the code which will de-escape data after loading, but it will not solve the problem. ( you will have an escaped data in database - which is probably a wrong result )

Thanx for reply. I’ve checked the DB and there are no HTML encoding there. I use unicode as storage. Attached pic.

I don’t understand at what stage the textarea gets HTML encoded. Is there some .html or .text property on the event object?

I did a small test with a function replacing just a quote. I applied it to both event_bar_text and event_text but only the event_bar_text is changed. Maybe I’m not calling my textarea correctly?

[code]//My lightbox config
scheduler.config.lightbox.sections = [
{ name: “person”, height: 21, map_to: “person”, type: “select”, focus: true, options: persons },
{ name: “task”, height: 21, map_to: “task”, type: “select”, options: tasks },
{ name: “role”, height: 21, map_to: “role”, type: “select”, options: roles },
{ name: “hour”, height: 21, map_to: “hour”, type: “select”, options: hours },
{ name: “text”, height: 50, map_to: “text”, type: “textarea”},
{ name: “time”, height: 72, type: “time”, map_to: “auto” }
];

//replace a quote character
function htmlReplace(str) {
return str.replace(/"/g, ‘I_have_replaced_a_quote’);
}

//scheduler template function
function my_new_text(start, end, ev) {
return htmlReplace(ev.text);
}

//apply on bar_text and text
scheduler.templates.event_bar_text = my_new_text;
scheduler.templates.event_text = my_new_text;[/code]

See picture.

I found a solution by using .attachEvent instead of templates as seen in another forum post here:
viewtopic.php?f=6&t=20373.

The following solves my problem:

scheduler.attachEvent("onLightbox", function (id) { var ev = scheduler.getEvent(id); var mytext = Encoder.htmlDecode(ev.text) mytext.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/g, "") //avoid cross scripting scheduler.formSection('text').setValue(mytext); });;

Now my textarea is decoded correctly. See pic.

You may try to add the next line to the scheduler’s init

dp.enableUTFencoding(false);

by default data is utf encoded, before sending to server side, which may cause the above effect. ( normally, when your server side scripts aware of utf, it is not a problem )