Opened 4 years ago

Closed 4 years ago

#13319 closed Bug (expired)

htmlEncodeOutput option not work for ajax submit if jquery adapter used

Reported by: 613038475 Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:

Description

Because jquery adapter will override the val function, the value post to server always not encoded.

I tried to set CKEDITOR.config.jqueryOverrideVal = false, but the val function still get override, I can confirm CKEDITOR.config.jqueryOverrideVal is false and attr("value") is encoded from firefox debug console, but the val function still return no encoded.

Change History (7)

comment:1 Changed 4 years ago by Jakub Ś

Status: newpending
Version: 4.4.8 (GitHub - master)

Could you provide reduced HTML file (set of files if needed) that allows reproducing this issue in default CKEditor?

NOTE: I'm particularly interested in how you are getting data from the editor. This is because

  1. Textarea is auto updated when you post the form in traditional way - http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-autoUpdateElement
  2. When you want to submit content via AJAX then you should update content of this textarea by calling editor.updateElement()

or get data directly from editor instance by editor.getData(), encode it if needed and put it into request manually.

comment:2 Changed 4 years ago by 613038475

jquery $.serialize use .val() to get value instead of .attr("value"), that's the reason. jquery adapter make .val() always return the non-encode html.

comment:3 Changed 4 years ago by Piotr Jasiun

When you call .val() on the CKEditor container, you will get the data returned by getData. Nothing less, nothing more. As I checked when you call .val() on the <textarea> you also do not get encoded data, so I do not see the point why CKEditor should do this. CKEditor replace <textarea> and it should return the same value as <textarea>.

comment:4 Changed 4 years ago by 613038475

the point is without jquery adapter, val() will return encoded html, with jquery adapter, val() will return non-encoded html.

so it will break the htmlEncodeOutput option with $serialize.

also I tried set CKEDITOR.config.jqueryOverrideVal = false, but val() still get override. so the only option is not use jquery adapter.

comment:5 Changed 4 years ago by Jakub Ś

the point is without jquery adapter, val() will return encoded html

@613038475 could you recheck this? Are you sure that you are not encoding val results manually somewhere in your application?

I'm asking because @pjasun has said:

As I checked when you call .val() on the <textarea> you also do not get encoded data

and at the moment we have two opposite statements.

Extra question from me: since data returend by adapter is not encoded, can't you encode it yourself manually before sending it to the server?

comment:6 Changed 4 years ago by Piotr Jasiun

I just checked it:

  1. Added jQuery to replacebycode.html sample.
  2. Call $( '#editor1' ).val();

And I get not encoded data.

Can you tell me what you did to get encoded html using val()? Some snippet would be perfect.

comment:7 Changed 4 years ago by Piotrek Koszuliński

Resolution: expired
Status: pendingclosed
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy