This is a migrated thread and some comments may be shown as answers.

[Solved] Incorrect Encode() behavior

1 Answer 174 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wicky
Top achievements
Rank 1
Wicky asked on 28 Apr 2012, 03:27 PM
Hi,

I put Edior component (latest public release) on a page and submit it to server side, and save data.

1) If set Encode(true):
I get the encoded content at server side without problem, but when I retrieve the saved data and bind to the Editor, Editor can't decode the encoded data and can't show the content properly.
For example,  I input "123", and posted data is "&lt;strong&gt;123&lt;/strong&gt;", when re-bind the data to Editor, it shows "<strong>123</strong>".

2) If set Encode(false):
I always get encoded content at server side, the value of hidden textarea is always encoded, so I get the .

I traced telerik.editor.js, and found this intresting function:
update: function (value) {
    this.textarea.value = value || this.encoded ? this.encodedValue() : this.value();
},
as traced, it equals below statement, which means the value parameter is never assigned to textarea, if value is passed in function, encodedValue is used
this.textarea.value = (value || this.encoded) ? this.encodedValue() : this.value();
so I wonder should it be:
this.textarea.value = value || (this.encoded ? this.encodedValue() : this.value());


and for the blur event, encoded setting is not considered, encodedValue is always used
$(editor.window)
    .bind('blur', function () {
        var old = editor.textarea.value,
        value = editor.encodedValue();
        editor.update(value);
        if (value != old) {
            $t.trigger(editor.element, 'change');
        }
    });
so I wonder should it be:
value = editor.encoded ? editor.encodedValue() : editor.value();

If I made above two changes, the value of hidden textarea will be non-encoded value.
Then for the first sample,  I input "123", and posted data is "<strong>123</strong>", when re-bind the data to Editor, it shows "123".

Could you check whether above two cases are designed or issues?

Regards
Wicky

1 Answer, 1 is accepted

Sort by
0
Mehmet
Top achievements
Rank 1
answered on 16 May 2012, 01:38 PM
Hi,

We have had the same problem for over 2 days. I just applied your two js changes and then it worked :)

I think this one is an issue, because it is annoying. The version is 2012.1.214.

Thank you very much!

Regards
Mehmet
Tags
Editor
Asked by
Wicky
Top achievements
Rank 1
Answers by
Mehmet
Top achievements
Rank 1
Share this question
or