Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#7329 closed Bug (invalid)

In non-source mode, text with html tags are rendered as html instead of as plain text with tags

Reported by: Rajasimhan Owned by:
Priority: Normal Milestone:
Component: General Version: 3.5.2
Keywords: Oracle Cc: senthil.kumaran@…

Description

Replication:

In non-source mode html text such as "<B> This is a sample text. </B>" when entered in the editor text area must be displayed as such ( i.e with tags and not as formatted html> once the text is saved. But on the contrary the html text is getting rendered into its corresponding html.

This issue occurs in CKeditor 3.3.1 also. We have customers on 3.3.1 also. CAn you provide a fix in 3.3.1 also?

Attachments (1)

replacebycode.html (3.4 KB) - added by Rajasimhan 8 years ago.
replacebycode.html

Download all attachments as: .zip

Change History (10)

comment:1 Changed 8 years ago by Rajasimhan

Summary: In non source mode editor renders text with html tags as html.In non-source mode, text with html tags are rendered as html instead of as plain text with tags

comment:2 Changed 8 years ago by Frederico Caldeira Knabben

Status: newpending

I'm not able to reproduce your problem.

I'm opening the editor and typing the exactly phrase you've used to exemplify: "<B> This is a sample text. </B>". The editor then outputs the following HTML:

<p>
	&lt;B&gt; This is a samples text . &lt;/B&gt;</p>

As you can see, the < and > chars have been transformed on HTML entities. So, you certainly expect them to render as plain text, not to style the text.

It also works well when loading this HTML in the editor. There is a common mistake though, which I think may be related to your problem.

When injecting HTML to be edited in a <textarea>, be sure to "html-encode" it first. The following way shows the bad and the good way to do so for this example:

<!-- This is wrong -->
<textarea><p>&lt;B&gt; This is a samples text . &lt;/B&gt;</p></textarea>

<!-- This is the correct way -->
<textarea>&lt;p&gt;&amp;lt;B&amp;gt; This is a samples text . &amp;lt;/B&amp;gt;&lt;/p&gt;</textarea>

This has nothing to do with the editor though. That's the way <textarea> works. If this is the issue you're having, it should be an easy to fix bug on your system.

Let us know!

comment:3 Changed 8 years ago by Rajasimhan

Cc: rajasimhan.baskar@… added

H fredck

The problem I have reported occurs when the editor is reloaded. If you test it using the demo editor in the website then I guess the editor is not reloaded if we save the text. That's why, in the steps below, I am requesting you to use the sample file and reload it.

1) Open the file ckeditor\_samples\replacebycode.html 2) Inside the textarea that corresponds to the editor type the following to add an encoded html snippet for an iframe.

<B>Testing</B>

once added it will look like this.

<textarea cols="80" id="editor1" name="editor1" rows="10">

<B>Testing</B>

</textarea>

4) Save the file 5) Now open the file in a browser. 6) Expected: <B>Testing</B>. ( as plain text in the editor).

observed: Editor will interpret the Tag and will display the word Testing in bold.

comment:4 Changed 8 years ago by Frederico Caldeira Knabben

Resolution: invalid
Status: pendingclosed

The editor will not convert plain text to HTML when loading it. It assumes the textarea it is replacing contains HTML data.

If you want the editor to load your data as plain text, you need to convert it by yourself before feeding the editor with it. Then, it will be up to your application to decide how to convert it (for example, how to deal with line breaks).

Changed 8 years ago by Rajasimhan

Attachment: replacebycode.html added

replacebycode.html

comment:5 in reply to:  4 Changed 8 years ago by Rajasimhan

Hi,

There was a slight mistake my previous post. I had added only encoded html snippet into the 'replacebycode.html'. But when i type the encoded snippet and save ( in this editor where i am reporting the bug) the editor is unencoding the html tag. So to you it appears as <B>Testing</B> instead of as encoded html.

I have attached the modified 'replacebycode.html' file with this post. In the modified file's html source I have replaced the editor 1's text areas content with a encoded html snippet. Just open the file and you will be able to see the problem. The encoded html is getting rendered.

comment:6 Changed 8 years ago by Rajasimhan

Hi,

There was a slight mistake in my previous post. I had added only encoded html snippet into the 'replacebycode.html'. But when I type the encoded snippet and save ( in this editor where i am reporting the bug) the editor is unencoding the html tag. So, to you, it appears as <B>Testing</B> instead of as an encoded html.

I have attached the modified 'replacebycode.html' file with this post. In the modified file's html source I have replaced the editor 1's text areas content with a encoded html snippet. Just open the file and you will be able to see the problem. The encoded html is getting rendered.

comment:7 Changed 8 years ago by Frederico Caldeira Knabben

Please ready my previous comment carefully. It shows to you the reason why your code is buggy.

You should not pass &lt;B&gt; to the textarea, but &amp;lt;B&amp;gt; instead. In other words, your contents must be "html-encoded" before outputting them inside the <textarea>.

comment:8 Changed 8 years ago by Rajasimhan

Cc: rajasimhan.baskar@… removed

Hi,

I agree with your comment. But from an end-user perspective, when I enter a text with html tag like <b> Test </b> and save the text, I would like to see the text in the same format and not rendered as html. Its getting rendered as html because the greater than sign '<' in the html tag is encoded as '&lt;' instead of as &amp;&lt;. This encoding has to be done by the ck editor when I save the page.

The html with the problem ( where & is not replaced by &amp ) is generated by ck editor when I press the view source button. Even in the demo editor in the website when you enter a html tag and click the view source button the encoded html does not encode & as &amp;. The problem is inherent in the editor. Our expectation is that ckeditor code should take care of encoding the & character with the code &amp;.

comment:9 Changed 8 years ago by Rajasimhan

Hi,

Any Updates on my comment? Can you please reopen the ticket.

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