.Net Editor library is encoding text when writing to DB

.Net Editor library is encoding text when writing to DB

kevan.watkinskevan.watkins Posts: 22Questions: 5Answers: 0

I am using Editor .NET Framework libraries v1.8.1 and mssql server.
When Editor writes to a varchar() field, the text is html encoded
i.e. "&" is written as "&"

Is there a way to disable this encoding?

This question has an accepted answers - jump to answer

Answers

  • kevan.watkinskevan.watkins Posts: 22Questions: 5Answers: 0

    I can solve it by adding the following to each text field:
    .SetFormatter((val, data) => System.Net.WebUtility.HtmlDecode(val.ToString()))

    Is there a better way?

  • tangerinetangerine Posts: 2,296Questions: 18Answers: 255

    I have no idea how similar the .NET library is to the PHP library, but this is my own note from a PHP Model using the Editor:

                // Disable XSS protection for the last_name field, 
                // otherwise ampersands will be neutralized by the DataTables
                // Editor's use of htmlAwed.
                // Neutralization refers to the entitification of & to &.
                ->xss(false),
    

    (chained from a Field::inst('last_name')).

    Might be some help.

  • allanallan Posts: 49,501Questions: 1Answers: 7,286 Site admin
    Answer ✓

    The libraries are all intentionally very similar. There are platform differences, like the .NET one uses Microsoft's own XSS protection filter rather than a third party one such as htmLawed. however, the same would be true here, if you aren't worried about XSS attacks then .Xss( false ) for the field would be what to use for .NET.

    Allan

  • kevan.watkinskevan.watkins Posts: 22Questions: 5Answers: 0

    Thank you both.
    That answers my question.

    I don't see how to mark it as Answered.

  • allanallan Posts: 49,501Questions: 1Answers: 7,286 Site admin

    The thread was opened as a discussion rather than a question. I've changed that now and marked it answered :).

    Allan

Sign In or Register to comment.