Opened 15 years ago

Closed 15 years ago

#5154 closed Bug (invalid)

ckeditor adds whitespace to tags in source

Reported by: routinet Owned by:
Priority: Normal Milestone:
Component: Core : Output Data Version: 3.1
Keywords: Cc:

Description (last modified by Alfonso Martínez de Lizarrondo)

When adding text with simple formats, fckeditor is inject whitespace between the tags, and between the tags and the content. When retrieving the same text from the database, the injected whitespace is interpreted as additional content, which is wrapped in its own set of tags. Each of the new tags receives the same injection of whitespace. Example:

Simple text:

<h1>text 1</h1>
<h1>text 2</h1>
<h1>text 3</h1>

After switch out and back into source:

<h1>
	text 1</h1>
<h1>
	text 2</h1>
<h1>
	text 3</h1>

After saving and reloading the text, and switching to source view:

<h1>
	<br />
	text 1</h1>
<p>
	&nbsp;</p>
<h1>
	<br />
	text 2</h1>
<p>
	&nbsp;</p>
<h1>
	<br />
	text 3</h1>

Doing the same again, with absolutely zero changes by the user:

<h1>
	<br />
	<br />
	<br />
	text 1</h1>
<p>
	&nbsp;</p>
<p>
	<br />
	&nbsp;</p>
<p>
	&nbsp;</p>
<h1>
	<br />
	<br />
	<br />
	text 2</h1>
<p>
	&nbsp;</p>
<p>
	<br />
	&nbsp;</p>
<p>
	&nbsp;</p>
<h1>
	<br />
	<br />
	<br />
	text 3</h1>

Change History (4)

comment:1 Changed 15 years ago by routinet

I have researched this bug in the ticket system, and found it also explained in http://dev.fckeditor.net/ticket/3260, which was closed as invalid. While the work-around described in that ticket does work, it is, in fact, a work-around, and this report describes a valid bug.

In order to completely remove the impact of this bug using the work-around, I would need to use dataProcessor.writer.setRules() on each possible element type in HTML. Also, the methods in the work-around are undocumented as far as I can tell.

This bug destroys the formatting of source even without the user changing anything. Over time (after a second save), it destroys the format of the resulting HTML output as well. That is not how I understand the word 'feature' to apply.

comment:2 Changed 15 years ago by routinet

To fix in PHP once the form is submitted:

$_POST['textarea_output']=preg_replace("/(\\r\\n)*[\\t ]*/",'',$_POST['textarea_output']);

comment:3 in reply to:  2 Changed 15 years ago by routinet

Replying to routinet:

To fix in PHP once the form is submitted:

$_POSTtextarea_output?=preg_replace("/(
r
n)*[
t ]*/",,$_POSTtextarea_output?);

Gave the wrong version. The correct version:

$_POST['textarea_output']=preg_replace("/(\\r\\n)+[\\t ]*/",'',$_POST['textarea_output']);

comment:4 Changed 15 years ago by Alfonso Martínez de Lizarrondo

Description: modified (diff)
Milestone: CKEditor 3.x
Resolution: invalid
Status: newclosed

The problem is that in some part of your server, you are replacing new lines (\r\n) with <br> and that's what you send back to CKEditor next time.

Try to use that sample HTML with a plain textarea (just disable the CKEditor call) and you'll see that you are getting also the <br> without your "wouraround".

The methods to configure the output formatting are documented at http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Output_Formatting

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy