Opened 4 years ago

Last modified 4 years ago

#11026 assigned Bug

Htmlentities of php start tag makes attributes empty in internet explorer

Reported by: Pieter Owned by: Jakub Ś
Priority: Normal Milestone:
Component: General Version: 4.0
Keywords: IE Cc:

Description

Firefox 24 or Chrome 30.0 on Win8:

In code editor:

<p><a href="&lt;?=$foo;?&gt;">Bar</a></p>

Toggle source to wysywyg and toggle back to code

<p><a href="&lt;?=$foo;?&gt;">Bar</a></p>

The result is the same.

IE10 (and other IE) Win8:

In code editor

<p><a href="&lt;?=$foo;?&gt;">Bar</a></p>

Switch to wysywyg and back to code

<p><a href="">Bar</a></p>

Result: href is empty

When I test this without a php start tag (loosing the ?) in IE10:

In code editor

<p><a href="&lt;=$foo;?&gt;">Bar</a></p>

Switch to wysywyg and back to code

<p><a href="&lt;=$foo;?&gt;">Bar</a></p>

The result is correct.


You can reproduce this on the CKEditor demo page.

In our environment it is the same but if I add the following to the config, it works:

config.protectedSource.push( /<\?[\s\S]*?\?>/g );
config.protectedSource.push( /&lt;\?[\s\S]*?\?&gt;/g );

But protectedSource is not something what we want to use.

Is this a bug? Thanks in advance

Change History (2)

comment:1 Changed 4 years ago by Pieter

I think it's got something to do with the IE fix (3341) in /core/dom.element.js:374

/**
 * Gets the inner HTML of this element.
 *
 *		var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b></div>' );
 *		alert( element.getHtml() ); // '<b>Example</b>'
 *
 * @returns {String} The inner HTML of this element.
 */
getHtml: function() {
	var retval = this.$.innerHTML;
	// Strip <?xml:namespace> tags in IE. (#3341).
	return CKEDITOR.env.ie ? retval.replace( /<\?[^>]*>/g, '' ) : retval;
},

Our fix but I doesn't cover the combination of a php tag and namespace tag:

	getHtml: function() {
		var retval = this.$.innerHTML;
		// Strip <?xml:namespace> tags in IE. (#3341).
		// unless it contains <? ?> 
		return (CKEDITOR.env.ie && ! retval.test( /<\?.*\?>/ )) ? retval.replace( /<\?[^>]*>/g, '' ) : retval;
	},

comment:2 Changed 4 years ago by Jakub Ś

Keywords: IE added
Owner: set to Jakub Ś
Status: newassigned
Version: 4.2.24.0

NOTE: CKEditor is HTML editor so if you are using php you should use protectedSource.

Now back to the problem. I think regex should be changed to:

/<^\?[^>]*>/g

Since xml:namespace starts with ? it should work for both cases.

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