Problem including ampersands using Editor

Problem including ampersands using Editor

crichardcrichard Posts: 2Questions: 1Answers: 0

Hi,

I have this problem when using Editor with special characters:
When updating a field (e.g. using a Bubble editor or whatever) to include ampersands in one of the fields, Editor encodes the value by transforming "&" into "&". So that's how it will show up in the database. But I need the ampersand to remain just "&" in the DB.
How can I prevent Editor from encoding these ampersands?

I see that this is happening in one of your own examples, though the encoding doesn't show:
https://editor.datatables.net/examples/inline-editing/simple.html
I tried using Firefox's developer mode, Network tab.
When you edit something in that page by adding an ampersand to a LastName, it sends a POST to staff.php.
If I look at the response of that POST, I see that the data in the response contains the encoded string "&".

More details:

I'm using the .NET library in C#
In the MVC controller in debugging mode, it comes to this line:

response.Process(dtReq);  // response is of type DataTables.Editor

At this point the object dtReq looks completely fine. The items in dtReq.Data are not encoded, e.g. "blah & blah" and not "blah & blah".
But as soon as that line gets executed, the database has the encoded version: "blah & blah".

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Use the Field.Xss(false) method to disable the XSS protection that Editor uses.

    Regards,
    Allan

  • crichardcrichard Posts: 2Questions: 1Answers: 0

    Thanks Allan! That worked great.

This discussion has been closed.