Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#107 closed Bug (wontfix)

Impossible to use PHP inside tag definitions

Reported by: micha.wotton@… Owned by:
Priority: Normal Milestone:
Component: General Version: FCKeditor 2.4
Keywords: CantFix Cc:

Description

It seems the ternary operator ('?') can be confused with the PHP closing tag ('?>') when embedding PHP code in the edited content.

I have enabled the Protected code option for PHP, and for the most part the PHP is left alone. However, whenever I use the ternary operator to generate options within HTML tags, the next PHP closing tag is interpreted as closing the HTML tag. For example the code

<input type="radio" name="stype" <?php echo ($i == 0) ? (" on") : ("") ; ?> id="stype<?php echo $i; ?>" value="<?php echo $subsDetail['type'] ; ?>" />

becomes

<input type="radio" name="stype" value="on" /> id=&quot;stype<?=$i?>&quot; value=&quot;<?php echo $subsDetail['type'] ; ?>&quot; /&gt;

after switching from the source.

This is not the end of the world as I can just use if/else statements instead, it is a pain however.

Change History (5)

comment:1 Changed 13 years ago by micha.wotton@…

On further inspection (I apologise for being hasty) it seems it is not the ternary operator, but some PHP blocks within an HTML input tag. I have some examples here:

<form name="subsdetail" id="subsdetail" action="<?php echo 
$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'] ; ?>" method="post">

is left untouched.

However

<input type="radio" name="stype" 
<?php if ($i == 0) { echo ' checked'; } ?> id="stype<?php echo $i; ?>" 
value="<?php echo $subsDetail['type'] ; ?>" />

becomes

<input type="radio" name="stype"
 value="on" /> id=&quot;stype<?php echo $i; ?>&quot; 
value=&quot;<?php echo $subsDetail['type'] ; ?>&quot; /&gt;

However if I swap the order of parameters in the second example:

<input type="radio" name="stype" id="stype<?php echo $i; ?>" 
value="<?php echo $subsDetail['type'] ; ?>" 
<?php if ($i == 0) { echo ' checked'; } ?>

it leaves the first two blocks alone and just messes up the last block:

<input id="stype<?php echo $i; ?>" type="radio" name="stype" 
value="<?php echo $subsDetail['type'] ; ?>" /> /&gt;

(it has, however changed the order of some of the parameters...)

comment:2 Changed 13 years ago by Frederico Caldeira Knabben

Component: Server : PHPGeneral
Keywords: CantFix added; ternary removed
Owner: Frederico Caldeira Knabben deleted

The fact is that the ProtectedSource feature will not work inside tags declarations.

To protect content, FCKeditor uses a Regex to remove it from the original source, moving it to an Array. The original protected source is then replaced with a HTML comment, like <!-- PS:n -->, where "n" is the index of the protected data in the Array. The problem is that a comment is not allowed inside a tag declaration, and so the HTML gets broken in your case.

I don't see other ways to protect part of the original data, so I don't believe a fix for it will be ever available. So, when using FCKeditor, users must be aware of this limitation and work accordingly to it. So, your code must be rewritten... something like:

<?php 
echo '<input type="radio" name="stype" ' . ( ($i == 0) ? (" on") : ("") ) . ' id="stype' . $i . '" value="' . $subsDetail['type'] . '" />' ;
?>

comment:3 Changed 13 years ago by Frederico Caldeira Knabben

Summary: Ternary operator confused with PHP closing tagImpossible to use PHP inside tag definitions

comment:4 Changed 13 years ago by Frederico Caldeira Knabben

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